var egret = window.egret;var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = this && this.__extends || function __extends(t, e) { 
 function r() { 
 this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var TextField = (function (_super) {
    __extends(TextField, _super);
    function TextField() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return TextField;
}(egret.TextField));
__reflect(TextField.prototype, "TextField");
;
var Sprite = (function (_super) {
    __extends(Sprite, _super);
    function Sprite() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Sprite;
}(egret.Sprite));
__reflect(Sprite.prototype, "Sprite");
;
var Shape = (function (_super) {
    __extends(Shape, _super);
    function Shape() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Shape;
}(egret.Shape));
__reflect(Shape.prototype, "Shape");
;
var DisplayObject = (function (_super) {
    __extends(DisplayObject, _super);
    function DisplayObject() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return DisplayObject;
}(egret.DisplayObject));
__reflect(DisplayObject.prototype, "DisplayObject");
;
var DisplayObjectContainer = (function (_super) {
    __extends(DisplayObjectContainer, _super);
    function DisplayObjectContainer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return DisplayObjectContainer;
}(egret.DisplayObjectContainer));
__reflect(DisplayObjectContainer.prototype, "DisplayObjectContainer");
;
var Point = (function (_super) {
    __extends(Point, _super);
    function Point() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Point;
}(egret.Point));
__reflect(Point.prototype, "Point");
;
var Rectangle = (function (_super) {
    __extends(Rectangle, _super);
    function Rectangle() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Rectangle;
}(egret.Rectangle));
__reflect(Rectangle.prototype, "Rectangle");
;
var Bitmap = (function (_super) {
    __extends(Bitmap, _super);
    function Bitmap() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Bitmap;
}(egret.Bitmap));
__reflect(Bitmap.prototype, "Bitmap");
;
var BitmapData = (function (_super) {
    __extends(BitmapData, _super);
    function BitmapData() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return BitmapData;
}(egret.BitmapData));
__reflect(BitmapData.prototype, "BitmapData");
;
var Stage = (function (_super) {
    __extends(Stage, _super);
    function Stage() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Stage;
}(egret.Stage));
__reflect(Stage.prototype, "Stage");
;
var Tween = (function (_super) {
    __extends(Tween, _super);
    function Tween() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Tween;
}(egret.Tween));
__reflect(Tween.prototype, "Tween");
;
var Ease = (function (_super) {
    __extends(Ease, _super);
    function Ease() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Ease;
}(egret.Ease));
__reflect(Ease.prototype, "Ease");
;
//----------------------------------------------
//以下几种方法在使用前都必须先调用各自的初始化函数
//moon.TipsManager.getIns().init(this.stage);
//moon.LogManager.getIns().init(this.stage);
//moon.AlertManager.getIns().init(this.stage);
var trace = function () {
    var arg = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        arg[_i] = arguments[_i];
    }
    var str = "";
    for (var i = 0; i < arg.length; i++) {
        str += arg[i] + ",";
    }
    str = str.substr(0, str.length - 1);
    moon.LogManager.getIns().logMessage(str);
};
var traceSimple = function () {
    var arg = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        arg[_i] = arguments[_i];
    }
    var str = "";
    for (var i = 0; i < arg.length; i++) {
        str += arg[i] + ",";
    }
    str = str.substr(0, str.length - 1);
    moon.LogManager.getIns().log(str);
};
var alertAuto = function (title, closeTime) {
    if (title === void 0) { title = "提示或警告"; }
    if (closeTime === void 0) { closeTime = 3; }
    moon.AlertManager.getIns().alertAuto(title, closeTime);
};
var alertHand = function (title) {
    if (title === void 0) { title = "提示或警告"; }
    moon.AlertManager.getIns().alert(title);
};
var alertRoll = function (title, bgWidth) {
    if (title === void 0) { title = "提示或警告"; }
    if (bgWidth === void 0) { bgWidth = 200; }
    moon.AlertManager.getIns().alertRoll(title, bgWidth);
};
//----------------------------------------------
var moon;
(function (moon) {
    var FONT = (function () {
        function FONT() {
        }
        FONT.fontName = "黑体";
        return FONT;
    }());
    moon.FONT = FONT;
    __reflect(FONT.prototype, "moon.FONT");
    var Const = (function () {
        function Const() {
        }
        /**布局 横版*/
        Const.HORIZONTAL = "horizontal";
        /**布局 竖版*/
        Const.VERTICAL = "vertical";
        /**形状 方块*/
        Const.SHAPE_RECT = "shape rect";
        /**形状 圆角方块*/
        Const.SHAPE_RECT_ROUND = "shape rect round";
        /**形状 圆块*/
        Const.SHAPE_CIRCLE = "shape circle";
        /**版本 调试*/
        Const.VER_DEBUG = "debug";
        /**版本 发布*/
        Const.VER_RELEASE = "release";
        return Const;
    }());
    moon.Const = Const;
    __reflect(Const.prototype, "moon.Const");
    /**颜色 */
    var Color = (function () {
        function Color() {
        }
        Object.defineProperty(Color, "random", {
            get: function () { return Math.random() * 0XFFFFFF; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "white", {
            get: function () { return 0XFFFFFF; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "black", {
            get: function () { return 0X000000; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "gray", {
            get: function () { return 0X666666; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "red", {
            get: function () { return 0XFF0000; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "green", {
            get: function () { return 0X00FF00; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "bule", {
            get: function () { return 0X0000FF; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "skinNormal", {
            get: function () { return 0X15191C; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "skinDown", {
            get: function () { return 0X999999; },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Color, "titleBackground", {
            get: function () { return 0X20262B; },
            enumerable: true,
            configurable: true
        });
        ;
        Color.getRandomArray = function (count) {
            var colors = [];
            for (var i = 0; i < count; i++)
                colors.push(Math.random() * 0XFFFFFF);
            return colors;
        };
        ;
        /** 可改变颜色的亮暗,value值是-255到255*/
        Color.lightenDarkenColor = function (color, value) {
            var r = (color >> 16) + value;
            if (r > 255)
                r = 255;
            else if (r < 0)
                r = 0;
            var b = ((color >> 8) & 0x00FF) + value;
            if (b > 255)
                b = 255;
            else if (b < 0)
                b = 0;
            var g = (color & 0x0000FF) + value;
            if (g > 255)
                g = 255;
            else if (g < 0)
                g = 0;
            return (g | (b << 8) | (r << 16));
        };
        return Color;
    }());
    moon.Color = Color;
    __reflect(Color.prototype, "moon.Color");
    /**皮肤 */
    var Skin = (function () {
        function Skin() {
        }
        Object.defineProperty(Skin, "randomRect", {
            get: function () { return moon.MoonUI.getRect(60, 60, moon.Color.random); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "randomCircle", {
            get: function () { return moon.MoonUI.getCircle(50, moon.Color.random); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "pointNormal", {
            /**默认点 */
            get: function () { return moon.MoonUI.getCircle(6, moon.Color.black); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "pointDown", {
            get: function () { return moon.MoonUI.getCircle(6, moon.Color.gray); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "buttonNormal", {
            /**默认按钮 */
            get: function () { return moon.MoonUI.getRect(60, 60, moon.Color.skinNormal); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "buttonDown", {
            get: function () { return moon.MoonUI.getRect(60, 60, moon.Color.skinDown); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "radioOff", {
            /**默认单选框 */
            get: function () { return moon.MoonUI.getRadioCircle(moon.Color.white, moon.Color.white); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "radioOn", {
            get: function () { return moon.MoonUI.getRadioCircle(moon.Color.white, moon.Color.black, 1); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "checkBoxOff", {
            /**默认复选框 */
            get: function () { return moon.MoonUI.getCheckBoxRect(moon.Color.white, moon.Color.white); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "checkBoxOn", {
            get: function () { return moon.MoonUI.getCheckBoxRect(moon.Color.white, moon.Color.black, 1); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "switchOff", {
            /**默认开关 */
            get: function () { return moon.MoonUI.getSwitch(moon.Color.skinNormal, moon.Color.white); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "switchOn", {
            get: function () { return moon.MoonUI.getSwitch(moon.Color.skinNormal, moon.Color.white, 1); },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(Skin, "progressBackground", {
            /**默认进度条 */
            get: function () { return moon.MoonUI.getRect(300, 20, moon.Color.skinNormal); },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Skin, "progressValue", {
            get: function () { return moon.MoonUI.getRect(300, 20, moon.Color.skinDown); },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Skin, "sliderBackground", {
            /**默认滑动器 */
            get: function () { return moon.MoonUI.getRect(300, 10, moon.Color.skinNormal); },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Skin, "sliderValue", {
            get: function () { return moon.MoonUI.getRect(300, 10, moon.Color.skinDown); },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Skin, "sliderBar", {
            get: function () { return moon.MoonUI.getCircle(15, moon.Color.white); },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Skin, "scrollBar", {
            /**默认滚动条 */
            get: function () { return moon.MoonUI.getRect(10, 10, moon.Color.skinNormal); },
            enumerable: true,
            configurable: true
        });
        Skin.getRodatioButton = function (label) {
            var btn = new BasicButton(moon.Skin.radioOff, moon.Skin.radioOn);
            btn.skinAutoScale = false;
            btn.label = label;
            btn.labelColor = moon.Color.black;
            btn.setLabelPoint(40, 0);
            return btn;
        };
        Skin.getCheckBox = function (label) {
            var skins = [moon.Skin.checkBoxOff, moon.Skin.checkBoxOff, moon.Skin.checkBoxOn, moon.Skin.checkBoxOn];
            var btn = new moon.MoreSkinButton(skins);
            btn.skinAutoScale = false;
            btn.label = label;
            btn.toggleSwitch = true;
            btn.labelColor = moon.Color.black;
            btn.setLabelPoint(50, 2);
            return btn;
        };
        return Skin;
    }());
    moon.Skin = Skin;
    __reflect(Skin.prototype, "moon.Skin");
    /**
     * ...
     * 简单的布局
     * @author vinson
     */
    var SimpleLayout = (function () {
        function SimpleLayout() {
        }
        /**参数：数组,X轴个数,X轴距离,Y轴距离,X轴位置,Y轴位置,正排/反排 */
        SimpleLayout.displayRank = function (array, xNum, xDis, yDis, x, y, sign) {
            if (xNum === void 0) { xNum = 1; }
            if (xDis === void 0) { xDis = 0; }
            if (yDis === void 0) { yDis = 0; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            if (sign === void 0) { sign = 1; }
            var display;
            for (var i = 0; i < array.length; i++) {
                display = array[i];
                display.x = x + Math.floor(i % xNum) * (display.width + xDis) * sign;
                display.y = y + Math.floor(i / xNum) * (display.height + yDis) * sign;
            }
        };
        return SimpleLayout;
    }());
    moon.SimpleLayout = SimpleLayout;
    __reflect(SimpleLayout.prototype, "moon.SimpleLayout");
    /**
     * ...
     * 默认参数x轴,y轴,w宽,h高,r半径,c颜色,ew圆角宽,eh圆家高
     * @author vinson
     */
    var MoonUI = (function () {
        function MoonUI() {
        }
        Object.defineProperty(MoonUI, "randomColor", {
            /**得到随机色*/
            get: function () {
                return Math.random() * 0XFFFFFF;
            },
            enumerable: true,
            configurable: true
        });
        /**得到矩形框*/
        MoonUI.getLineRect = function (w, h, c, s, x, y) {
            if (c === void 0) { c = 0; }
            if (s === void 0) { s = 1; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var node = new Sprite();
            node.graphics.lineStyle(s, c);
            node.graphics.drawRect(x, y, w, h);
            node.graphics.endFill();
            return node;
        };
        /**得到圆形框*/
        MoonUI.getLineCircle = function (r, c, s, x, y) {
            if (c === void 0) { c = 0; }
            if (s === void 0) { s = 1; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var node = new Sprite();
            node.graphics.lineStyle(s, c);
            node.graphics.drawCircle(x, y, r);
            node.graphics.endFill();
            return node;
        };
        /**得到渐变矩形 a为角度偏移率0,0.5,1,2分别为四个正方向*/
        MoonUI.getMatrixRect = function (w, h, c1, c2, a) {
            if (c1 === void 0) { c1 = 0; }
            if (c2 === void 0) { c2 = 0; }
            if (a === void 0) { a = 0; }
            var node = new Sprite();
            var matrix = new egret.Matrix();
            matrix.createGradientBox(w, h, Math.PI * a, 0, 0);
            node.graphics.beginGradientFill(egret.GradientType.LINEAR, [c1, c2], [1, 1], [0, 255], matrix);
            node.graphics.drawRect(0, 0, w, h);
            node.graphics.endFill();
            return node;
        };
        /**得到矩形*/
        MoonUI.getRect = function (w, h, c, x, y) {
            if (c === void 0) { c = 0; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var s = new Sprite();
            s.graphics.beginFill(c);
            s.graphics.drawRect(x, y, w, h);
            s.graphics.endFill();
            return s;
        };
        /**得到矩形和一个X*/
        MoonUI.getRectAndX = function (w, h, c, x, y) {
            if (c === void 0) { c = 0; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var s = this.getRect(w, h, c, x, y);
            s.addChild(this.getX(w, h, c, 1, x, y));
            return s;
        };
        /**得到矩形和一个X*/
        MoonUI.getX = function (w, h, c, s, x, y) {
            if (c === void 0) { c = 0; }
            if (s === void 0) { s = 1; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var container = new Sprite;
            var l1 = new Sprite;
            l1.graphics.lineStyle(s, c);
            l1.graphics.moveTo(0, 0);
            l1.graphics.lineTo(w, h);
            var l2 = new Sprite;
            l2.graphics.lineStyle(s, c);
            l2.graphics.moveTo(w, 0);
            l2.graphics.lineTo(0, h);
            container.addChild(l1);
            container.addChild(l2);
            return container;
        };
        /**得到圆角矩形*/
        MoonUI.getRoundRect = function (w, h, c, ew, eh, x, y) {
            if (c === void 0) { c = 0; }
            if (ew === void 0) { ew = 5; }
            if (eh === void 0) { eh = 5; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var s = new Sprite();
            s.graphics.beginFill(c);
            s.graphics.drawRoundRect(x, y, w, h, ew, eh);
            s.graphics.endFill();
            return s;
        };
        /**得到圆形*/
        MoonUI.getCircle = function (r, c, x, y) {
            if (c === void 0) { c = 0; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var s = new Sprite();
            s.graphics.beginFill(c);
            s.graphics.drawCircle(x, y, r);
            s.graphics.endFill();
            return s;
        };
        /**得到多边形,side边数,rotation角度*/
        MoonUI.getPolygon = function (side, r, c, rotation) {
            if (side === void 0) { side = 3; }
            if (r === void 0) { r = 10; }
            if (c === void 0) { c = 0; }
            if (rotation === void 0) { rotation = 0; }
            var s = new Sprite;
            s.rotation = rotation;
            s.graphics.beginFill(c);
            for (var i = 0; i <= side; i++) {
                var lineX = Math.cos((i * (360 / side) * Math.PI / 180)) * r;
                var lineY = Math.sin((i * (360 / side) * Math.PI / 180)) * r;
                if (i == 0)
                    s.graphics.moveTo(lineX, lineY);
                else
                    s.graphics.lineTo(lineX, lineY);
            }
            s.graphics.endFill();
            return s;
        };
        /**得到圆角矩形与三角形合体rc是正方形颜色,pc是三角形颜色*/
        MoonUI.getArrowRoundRect = function (w, h, rc, pc, rotation) {
            if (pc === void 0) { pc = 0; }
            if (rotation === void 0) { rotation = 0; }
            var s = new Sprite;
            s.addChild(this.getRoundRect(w, h, rc));
            var p = this.getPolygon(3, w / 3, pc, 30 + rotation);
            p.x = s.width >> 1;
            p.y = s.height >> 1;
            s.addChild(p);
            return s;
        };
        /**得到滚动条的bar*/
        MoonUI.getScrollLineBar = function (w, h, c) {
            var s = new Sprite;
            var _h = h / 3;
            for (var i = 0; i < 3; i++) {
                var r = this.getRect(w, 1, c, 0, i * _h);
                s.addChild(r);
            }
            return s;
        };
        /**得到圆角矩形-加*/
        MoonUI.getAddRoundRect = function (w, h, c) {
            var s = new Sprite;
            s.addChild(this.getRoundRect(w, h, c));
            var r1 = this.getRect(w / 2, 2, 0, w / 4, h / 2 - 1);
            var r2 = this.getRect(2, h / 2, 0, w / 2 - 1, h / 4);
            s.addChild(r1);
            s.addChild(r2);
            return s;
        };
        /**得到圆角矩形-减*/
        MoonUI.getRemoveRoundRect = function (w, h, c) {
            var s = new Sprite;
            s.addChild(this.getRoundRect(w, h, c));
            var r = this.getRect(w / 2, 2, 0, w / 4, h / 2 - 1);
            s.addChild(r);
            return s;
        };
        /**得到带文字的圆角方形*/
        MoonUI.getRoundRectText = function (w, h, c, str) {
            if (str === void 0) { str = "click"; }
            var s = new Sprite;
            s.addChild(this.getRoundRect(w, h, c));
            var text = new TextField;
            text.name = "text";
            text.text = str;
            text.x = (s.width - text.width) >> 1;
            text.y = (s.height - text.height) >> 1;
            s.addChild(text);
            return s;
        };
        /**得到矩形-switchButton bc背景颜色，gc钩选的颜色,type为0是没有钩为1是有钩*/
        MoonUI.getSwitch = function (bc, gc, type) {
            if (bc === void 0) { bc = 0XFFFFFF; }
            if (gc === void 0) { gc = 0; }
            if (type === void 0) { type = 0; }
            var node = moon.MoonUI.getRoundRect(80, 50, bc, 60, 60);
            node.addChild(moon.MoonUI.getCircle(22, gc, type == 0 ? 25 : 55, 25));
            return node;
        };
        /**得到矩形-复选框 bc背景颜色，gc钩的颜色,type为0是没有钩为1是有钩*/
        MoonUI.getCheckBoxRect = function (bc, gc, type) {
            if (bc === void 0) { bc = 0XFFFFFF; }
            if (gc === void 0) { gc = 0; }
            if (type === void 0) { type = 0; }
            var s = new Sprite;
            s.addChild(this.getRect(40, 40, bc));
            if (type == 1) {
                var r = new Sprite;
                r.graphics.beginFill(gc);
                r.graphics.moveTo(0, 20);
                r.graphics.lineTo(20, 36);
                r.graphics.lineTo(44, 8);
                r.graphics.lineTo(36, 0);
                r.graphics.lineTo(20, 18);
                r.graphics.lineTo(12, 8);
                r.graphics.lineTo(0, 20);
                s.addChild(r);
            }
            return s;
        };
        /**得到矩形-单选框 bc背景颜色，gc钩的颜色,type为0是没有圆为1是有圆*/
        MoonUI.getRadioCircle = function (bc, gc, type) {
            if (bc === void 0) { bc = 0XFFFFFF; }
            if (gc === void 0) { gc = 0; }
            if (type === void 0) { type = 0; }
            var s = new Sprite;
            s.addChild(this.getCircle(16, bc, 16, 16));
            s.graphics.lineStyle(1, 0);
            if (type == 1) {
                var r = this.getCircle(8, gc, 16, 16);
                s.addChild(r);
            }
            return s;
        };
        /**得到矩形-网格
         * rect.x是x轴数量
         * rect.y是y轴数量
         * rect.width是网格宽
         * rect.height是网格高
         * lc网格线颜色
         * */
        MoonUI.getGridding = function (rect, c) {
            if (c === void 0) { c = 0; }
            var s = new Sprite;
            s.graphics.lineStyle(0.1, c);
            var disx = rect.width / rect.x;
            var disy = rect.height / rect.y;
            for (var i = 0; i < rect.x; i++) {
                s.graphics.moveTo(0, i * disy);
                s.graphics.lineTo(rect.width, i * disy);
            }
            for (i = 0; i < rect.y; i++) {
                s.graphics.moveTo(i * disx, 0);
                s.graphics.lineTo(i * disx, rect.height);
            }
            return s;
        };
        /***得到爱心 */
        MoonUI.getHeart = function (r, c) {
            if (r === void 0) { r = 15; }
            if (c === void 0) { c = 0XFF0000; }
            var s = new Sprite;
            s.graphics.beginFill(c);
            s.graphics.moveTo(0, 0);
            s.graphics.lineTo(0, -r * 2);
            s.graphics.cubicCurveTo(r, -r * 2.5, r * 2, -r * 1.5, 0, 0);
            s.graphics.moveTo(0, 0);
            s.graphics.lineTo(0, -r * 2);
            s.graphics.cubicCurveTo(-r, -r * 2.5, -r * 2, -r * 1.5, 0, 0);
            s.graphics.endFill();
            s.anchorOffsetX = -s.width / 2;
            s.anchorOffsetY = -s.height;
            return s;
        };
        return MoonUI;
    }());
    moon.MoonUI = MoonUI;
    __reflect(MoonUI.prototype, "moon.MoonUI");
    //--------------
    var LogManager = (function () {
        function LogManager() {
        }
        LogManager.getIns = function () {
            if (this.instance == null) {
                this.instance = new LogManager();
            }
            return this.instance;
        };
        /**请先调用初始化函数 */
        LogManager.prototype.init = function (stage) {
            var txt = (new Label).textField;
            stage.addChild(txt);
            txt.textAlign = egret.HorizontalAlign.LEFT;
            this.txtSimple = txt;
            var txt = (new Label).textField;
            txt.size = 25;
            stage.addChild(txt);
            this.txtMessage = txt;
        };
        /**每次都覆盖上一次信息 */
        LogManager.prototype.debug = function (value) {
            this.txtSimple.text = value;
        };
        /**每次都覆盖上一次信息 */
        LogManager.prototype.log = function (value) {
            if (GameData.version == Const.VER_DEBUG)
                this.txtSimple.text = value;
        };
        /**显示所有信息 */
        LogManager.prototype.logMessage = function (value) {
            if (GameData.version == Const.VER_DEBUG)
                this.txtMessage.appendText(value + "\n");
        };
        LogManager.prototype.setLogColor = function (color) {
            this.txtSimple.textColor = color;
        };
        LogManager.prototype.setLogMessageColor = function (color) {
            this.txtMessage.textColor = color;
        };
        return LogManager;
    }());
    moon.LogManager = LogManager;
    __reflect(LogManager.prototype, "moon.LogManager");
    //--------------
    var AlertManager = (function () {
        function AlertManager() {
        }
        AlertManager.getIns = function () {
            if (this.instance == null) {
                this.instance = new AlertManager();
            }
            return this.instance;
        };
        /**请先调用初始化函数 */
        AlertManager.prototype.init = function (stage) {
            this.stage = stage;
        };
        AlertManager.prototype.alertAuto = function (title, closeTime) {
            if (title === void 0) { title = "自动关闭的提示或警告"; }
            if (closeTime === void 0) { closeTime = 3; }
            var a = new AlertAutoBar(title, closeTime);
            if (this.stage)
                this.stage.addChild(a);
            else
                trace("调用alertAuto时请先执行AlertManager的init初始化函数");
            return a;
        };
        AlertManager.prototype.alert = function (title) {
            if (title === void 0) { title = "手动关闭的提示或警告"; }
            var a = new AlertBar(title);
            if (this.stage)
                this.stage.addChild(a);
            else
                trace("调用alertAuto时请先执行AlertManager的init初始化函数");
            return a;
        };
        AlertManager.prototype.alertRoll = function (title, bgWidth) {
            if (title === void 0) { title = "提示或警告"; }
            if (bgWidth === void 0) { bgWidth = 200; }
            var a = new AlertRollBar(title, bgWidth);
            if (this.stage)
                this.stage.addChild(a);
            else
                trace("调用alertAuto时请先执行AlertManager的init初始化函数");
            return a;
        };
        return AlertManager;
    }());
    moon.AlertManager = AlertManager;
    __reflect(AlertManager.prototype, "moon.AlertManager");
    var TipsManager = (function () {
        function TipsManager() {
            this.bgName = "tips_png"; //TIPS的背景图片
        }
        TipsManager.getIns = function () {
            if (this.instance == null) {
                this.instance = new TipsManager();
            }
            return this.instance;
        };
        /**请先调用初始化函数 */
        TipsManager.prototype.init = function (stage) {
            this.stage = stage;
        };
        TipsManager.prototype.simpleTips = function (value, pos) {
            if (this.tipsView == null) {
                this.tipsView = new moon.BasicTips(this.bgName);
                this.tipsView.setValue(value);
                this.stage.addChild(this.tipsView);
                this.setPosition(pos);
                this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.removeTips, this);
            }
        };
        TipsManager.prototype.setPosition = function (pos) {
            if (pos) {
                this.tipsView.x = pos.x - (this.tipsView.width >> 1);
                this.tipsView.y = pos.y - this.tipsView.height * 2;
                if (this.tipsView.y < 0) {
                    this.tipsView.y = pos.y;
                }
                if ((this.tipsView.y + this.tipsView.height) > this.stage.stageHeight) {
                    this.tipsView.y = pos.y - (this.tipsView.height + 50);
                }
                if (this.tipsView.x < 0) {
                    this.tipsView.x = pos.x + 50;
                }
                if ((this.tipsView.x + this.tipsView.width) > this.stage.stageWidth) {
                    this.tipsView.x = pos.x - (this.tipsView.width + 50);
                }
            }
        };
        TipsManager.prototype.removeTips = function () {
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.removeTips, this);
            var parent = this.tipsView.parent;
            if (parent != null) {
                parent.removeChild(this.tipsView);
                this.tipsView = null;
            }
        };
        return TipsManager;
    }());
    moon.TipsManager = TipsManager;
    __reflect(TipsManager.prototype, "moon.TipsManager");
    var MoonEvent = (function (_super) {
        __extends(MoonEvent, _super);
        function MoonEvent(type, data, currentTarget) {
            if (type === void 0) { type = ""; }
            if (data === void 0) { data = null; }
            if (currentTarget === void 0) { currentTarget = null; }
            var _this = _super.call(this) || this;
            _this.type = type;
            _this.data = data;
            _this.currentTarget = currentTarget;
            return _this;
        }
        //button event
        MoonEvent.MOUSE_OVER = "event-over"; //移进
        MoonEvent.MOUSE_OUT = "event-out"; //移出
        MoonEvent.MOUSE_DOWN = "event-down"; //点下
        MoonEvent.MOUSE_MOVE = "event-move"; //移动
        MoonEvent.MOUSE_UP = "event-up"; //弹开
        MoonEvent.CLICK = "event-click"; //单击
        //tabbar event
        MoonEvent.CHANGE = "change"; //更换
        MoonEvent.COMPLETE = "complete"; //完成
        MoonEvent.RENDER_COMPLETE = "render complete"; //渲染完成
        MoonEvent.UPDATE = "update"; //更新
        MoonEvent.START = "start"; //开始
        MoonEvent.MOVE = "move"; //移动
        MoonEvent.OVER = "over"; //结束
        MoonEvent.PAUSE = "pause"; //暂停
        MoonEvent.STOP = "stop"; //停止
        MoonEvent.PLAY = "play"; //播放
        MoonEvent.OPEN = "open"; //开启
        MoonEvent.CLOSE = "close"; //关闭
        return MoonEvent;
    }(egret.EventDispatcher));
    moon.MoonEvent = MoonEvent;
    __reflect(MoonEvent.prototype, "moon.MoonEvent");
    var MoonDisplayObject = (function (_super) {
        __extends(MoonDisplayObject, _super);
        function MoonDisplayObject() {
            var _this = _super.call(this) || this;
            _this._type = Const.SHAPE_RECT;
            _this._color = 0;
            _this.display = new Sprite;
            _this.bg = new Sprite;
            return _this;
        }
        Object.defineProperty(MoonDisplayObject.prototype, "type", {
            get: function () { return this._type; },
            set: function (value) { this._type = value; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(MoonDisplayObject.prototype, "color", {
            get: function () { return this._color; },
            set: function (value) { this._color = value; this._data.c = value; this.draw(); },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(MoonDisplayObject.prototype, "data", {
            /**{w:1,h:1,r:1,c:1,ew:1,eh:1} */
            set: function (value) { this._data = value; this.draw(); },
            enumerable: true,
            configurable: true
        });
        MoonDisplayObject.prototype.draw = function () {
            this._color = this._data.c;
            this.display.graphics.clear();
            this.display = this.getDisplay(this._data);
            this.addChild(this.display);
            this.setPosition();
        };
        MoonDisplayObject.prototype.setPosition = function () {
            if (this._hasBg && this.type != Const.SHAPE_CIRCLE) {
                this.display.x = (this.bg.width - this.display.width) >> 1;
                this.display.y = (this.bg.height - this.display.height) >> 1;
            }
        };
        MoonDisplayObject.prototype.setBackground = function (color, side) {
            if (side === void 0) { side = 1; }
            this._hasBg = true;
            var d = this._data;
            var o = {};
            for (var i in d) {
                o[i] = d[i];
            }
            o.c = color;
            if (o.w)
                o.w = o.w + side * 2;
            if (o.h)
                o.h = o.h + side * 2;
            if (o.r)
                o.r = o.r + side;
            this.bg.graphics.clear();
            this.bg = this.getDisplay(o);
            this.addChildAt(this.bg, 0);
            this.setPosition();
        };
        MoonDisplayObject.prototype.getDisplay = function (o) {
            switch (this.type) {
                case Const.SHAPE_RECT:
                    return MoonUI.getRect(o.w, o.h, o.c);
                case Const.SHAPE_RECT_ROUND:
                    return MoonUI.getRoundRect(o.w, o.h, o.c, o.ew, o.eh);
                case Const.SHAPE_CIRCLE:
                    return MoonUI.getCircle(o.r, o.c);
            }
        };
        return MoonDisplayObject;
    }(Sprite));
    moon.MoonDisplayObject = MoonDisplayObject;
    __reflect(MoonDisplayObject.prototype, "moon.MoonDisplayObject");
    var MoonContainer = (function (_super) {
        __extends(MoonContainer, _super);
        function MoonContainer() {
            var _this = _super.call(this) || this;
            _this.dataEvent = new Object;
            _this.init();
            _this.once(egret.Event.ADDED_TO_STAGE, _this.addToStage, _this);
            return _this;
        }
        MoonContainer.prototype.addToStage = function () {
            this.render();
        };
        /**加载到舞台之前调用 */
        MoonContainer.prototype.init = function () {
        };
        /**加载到舞台之后调用 */
        MoonContainer.prototype.render = function () {
            this.stageWidth = this.stage.stageWidth;
            this.stageHeight = this.stage.stageHeight;
        };
        /**发布事件*/
        MoonContainer.prototype.dispEvent = function (type, data, dataType) {
            if (data === void 0) { data = null; }
            if (dataType === void 0) { dataType = null; }
            if (this.dataEvent) {
                var fun = this.dataEvent[type];
                if (fun != null) {
                    var moonEvent = new MoonEvent;
                    moonEvent.currentTarget = this;
                    moonEvent.data = data;
                    moonEvent.type = type;
                    moonEvent.dataType = dataType;
                    if (fun["this"]) {
                        fun.apply(fun["this"], [moonEvent]);
                    }
                    else {
                        fun(moonEvent);
                    }
                }
            }
        };
        /**帧听事件*/
        MoonContainer.prototype.addEvent = function (type, listener, thisObj) {
            if (thisObj === void 0) { thisObj = null; }
            if (this.dataEvent && this.dataEvent[type] == null) {
                listener["this"] = thisObj;
                this.dataEvent[type] = listener;
            }
        };
        /**删除事件*/
        MoonContainer.prototype.removeEvent = function (type, listener) {
            if (this.dataEvent && this.dataEvent[type]) {
                delete this.dataEvent[type];
            }
        };
        /**把自己从父级删除*/
        MoonContainer.prototype.removeFromParent = function (value) {
            if (value === void 0) { value = false; }
            var _parent = this.parent;
            if (value)
                this.dispose();
            if (_parent && _parent.contains(this))
                _parent.removeChild(this);
            _parent = null;
        };
        /**删除所有的*/
        MoonContainer.prototype.removeChildAll = function (beginIndex, endIndex, dispose) {
            if (beginIndex === void 0) { beginIndex = 0; }
            if (endIndex === void 0) { endIndex = 2147483647; }
            if (dispose === void 0) { dispose = false; }
            if (endIndex < 0 || endIndex >= this.numChildren)
                endIndex = this.numChildren - 1;
            for (var i = beginIndex; i <= endIndex; ++i)
                this.removeChildIndex(beginIndex, dispose);
        };
        /**删除index层的*/
        MoonContainer.prototype.removeChildIndex = function (beginIndex, dispose) {
            if (beginIndex >= 0 || beginIndex < this.numChildren) {
                var basicContent = this.getChildAt(beginIndex);
                if (basicContent instanceof MoonContainer) {
                    basicContent.removeFromParent(dispose);
                }
                else {
                    var display = this.getChildAt(beginIndex);
                    if (display.parent)
                        display.parent.removeChild(display);
                }
            }
        };
        /**销毁*/
        MoonContainer.prototype.dispose = function () {
            this.removeChildAll(0, -1, true);
            this.dataEvent = null;
            this.stageWidth = null;
            this.stageHeight = null;
        };
        return MoonContainer;
    }(DisplayObjectContainer));
    moon.MoonContainer = MoonContainer;
    __reflect(MoonContainer.prototype, "moon.MoonContainer");
    var BasicView = (function (_super) {
        __extends(BasicView, _super);
        function BasicView() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        BasicView.prototype.createText = function (x, y, s) {
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            if (s === void 0) { s = ""; }
            var text = (new Label).textField;
            text.x = x;
            text.y = y;
            text.text = s;
            this.addChild(text);
            return text;
        };
        BasicView.prototype.createRect = function (w, h, c, x, y) {
            if (c === void 0) { c = 0; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var sprite = moon.MoonUI.getRect(w, h, c, x, y);
            this.addChild(sprite);
            return sprite;
        };
        BasicView.prototype.createCircle = function (r, c, x, y) {
            if (c === void 0) { c = 0; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var sprite = moon.MoonUI.getCircle(r, c, x, y);
            this.addChild(sprite);
            return sprite;
        };
        BasicView.prototype.createRectBySprite = function (s, w, h, c, x, y) {
            if (c === void 0) { c = 0; }
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            s.graphics.clear();
            s.graphics.beginFill(c);
            s.graphics.drawRect(x, y, w, h);
            s.graphics.endFill();
        };
        /**创建纯色背景 */
        BasicView.prototype.createBackground = function (c, a) {
            if (c === void 0) { c = 0; }
            if (a === void 0) { a = 1; }
            var s = this.createRect(this.stageWidth, this.stageHeight, c);
            s.alpha = a;
            s.touchEnabled = true; //用于阻止下层点击事件
            return s;
        };
        /**创建渐变色背景 */
        BasicView.prototype.createBgGradientFill = function (c1, c2) {
            if (c1 === void 0) { c1 = 0X017AC3; }
            if (c2 === void 0) { c2 = 0XDDDDDD; }
            var w = this.stageWidth;
            var h = this.stageHeight;
            var matrix = new egret.Matrix();
            matrix.createGradientBox(w, h, Math.PI / 2);
            var sprite = new Sprite;
            sprite.graphics.beginGradientFill(egret.GradientType.LINEAR, [c1, c2], [1, 1], [0, 255], matrix);
            sprite.graphics.drawRect(0, 0, w, h);
            this.addChild(sprite);
            return sprite;
        };
        return BasicView;
    }(MoonContainer));
    moon.BasicView = BasicView;
    __reflect(BasicView.prototype, "moon.BasicView");
    var GameView = (function (_super) {
        __extends(GameView, _super);
        function GameView() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        GameView.prototype.play = function () {
            this.stop();
            this.isPlay = true;
            egret.startTick(this.loop, this);
        };
        GameView.prototype.stop = function () {
            this.isPlay = false;
            egret.stopTick(this.loop, this);
        };
        GameView.prototype.loop = function (n) {
            traceSimple(n);
            return true;
        };
        GameView.prototype.createButton = function (name, x, y) {
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            var btn = new moon.BasicButton;
            btn.label = name;
            btn.x = x;
            btn.y = y;
            this.addChild(btn);
            return btn;
        };
        return GameView;
    }(BasicView));
    moon.GameView = GameView;
    __reflect(GameView.prototype, "moon.GameView");
    /**九宫格*/
    var Scale9Image = (function (_super) {
        __extends(Scale9Image, _super);
        function Scale9Image(name, rect) {
            if (rect === void 0) { rect = null; }
            var _this = _super.call(this) || this;
            if (RES.hasRes(name)) {
                _this.texture = RES.getRes(name);
                _this.scale9Grid = rect || new Rectangle(8, 8, 2, 2);
            }
            else {
                egret.error("找不到资源：" + name);
            }
            return _this;
        }
        return Scale9Image;
    }(Bitmap));
    moon.Scale9Image = Scale9Image;
    __reflect(Scale9Image.prototype, "moon.Scale9Image");
    var BasicTips = (function (_super) {
        __extends(BasicTips, _super);
        function BasicTips(skinName) {
            var _this = _super.call(this) || this;
            _this.side = 14; //文字离边框的距离
            _this.lineSpacing = 4; //行间距
            _this.image = new Scale9Image(skinName);
            _this.addChild(_this.image);
            _this.text = (new Label).textField;
            _this.text.textAlign = egret.HorizontalAlign.CENTER;
            _this.text.verticalAlign = egret.VerticalAlign.MIDDLE;
            _this.text.lineSpacing = _this.lineSpacing;
            _this.addChild(_this.text);
            return _this;
        }
        /**设置普通文字*/
        BasicTips.prototype.setValue = function (value) {
            this.text.text = value;
            this.setCenter();
        };
        // /**设置富文字 {text:"string",style:{"size":50,"textColor":0}}*/
        BasicTips.prototype.setTextFlow = function (textFlow) {
            this.text.textFlow = textFlow;
            this.setCenter();
        };
        BasicTips.prototype.setCenter = function () {
            var image = this.image;
            var text = this.text;
            var side = this.side;
            var w = text.width + side;
            var h = text.height + side;
            image.width = w;
            image.height = h;
            text.x = text.y = side >> 1;
        };
        return BasicTips;
    }(MoonContainer));
    moon.BasicTips = BasicTips;
    __reflect(BasicTips.prototype, "moon.BasicTips");
    var Label = (function (_super) {
        __extends(Label, _super);
        function Label(str, c) {
            if (str === void 0) { str = ""; }
            if (c === void 0) { c = 0XFFFFFF; }
            var _this = _super.call(this) || this;
            _this.text = new TextField;
            _this.text.textAlign = egret.HorizontalAlign.LEFT;
            _this.text.verticalAlign = egret.VerticalAlign.MIDDLE;
            _this.text.text = str;
            _this.text.textColor = c;
            _this.text.fontFamily = moon.FONT.fontName;
            _this.addChild(_this.text);
            return _this;
        }
        Object.defineProperty(Label.prototype, "textField", {
            get: function () {
                return this.text;
            },
            enumerable: true,
            configurable: true
        });
        return Label;
    }(MoonContainer));
    moon.Label = Label;
    __reflect(Label.prototype, "moon.Label");
    var BasicButton = (function (_super) {
        __extends(BasicButton, _super);
        function BasicButton(normal, down) {
            if (normal === void 0) { normal = null; }
            if (down === void 0) { down = null; }
            var _this = _super.call(this) || this;
            /**皮肤大小随字体大小变化 */
            _this.skinAutoScale = true;
            _this.statusNormal = normal || Skin.buttonNormal;
            _this.statusDown = down || Skin.buttonDown;
            _this.skinContainer = new DisplayObjectContainer;
            _this.addChild(_this.skinContainer);
            _this.updateSkin(_this.statusNormal);
            _this.text = (new Label).textField;
            _this.addChild(_this.text);
            _this.open();
            return _this;
        }
        BasicButton.prototype.open = function () {
            this.close();
            this.touchEnabled = true;
            this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
        };
        BasicButton.prototype.close = function () {
            this.touchEnabled = false;
            this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
            if (this.stage)
                this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
        };
        BasicButton.prototype.setLabelPoint = function (x, y) {
            this.text.anchorOffsetX = 0;
            this.text.anchorOffsetY = 0;
            this.text.x = x;
            this.text.y = y;
        };
        Object.defineProperty(BasicButton.prototype, "labelCircle", {
            set: function (value) {
                this.text.text = value;
                this.skinAutoScale = false;
                this.text.x = this.text.y = 0;
                this.text.anchorOffsetX = this.text.textWidth >> 1;
                this.text.anchorOffsetY = this.text.textHeight >> 1;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BasicButton.prototype, "labelColor", {
            set: function (value) {
                this.text.textColor = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BasicButton.prototype, "label", {
            get: function () {
                return this.text.text;
            },
            set: function (value) {
                this.text.text = value;
                var width = this.text.width + 20;
                this.setSkinSize();
                this.setTextPosition();
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BasicButton.prototype, "textFild", {
            get: function () {
                return this.text;
            },
            enumerable: true,
            configurable: true
        });
        /**设置富文字 {text:"string",style:{"size":50,"textColor":0}}*/
        BasicButton.prototype.setTextFlow = function (textFlow) {
            this.text.textFlow = textFlow;
            this.setSkinSize();
            this.setTextPosition();
        };
        BasicButton.prototype.setSkinNormal = function () {
            this.updateSkin(this.statusNormal);
        };
        BasicButton.prototype.setSkinDown = function () {
            this.updateSkin(this.statusDown);
        };
        BasicButton.prototype.onTouch = function (e) {
            if (e.type == egret.TouchEvent.TOUCH_BEGIN) {
                this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                this.updateSkin(this.statusDown);
            }
            else {
                this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                this.updateSkin(this.statusNormal);
            }
            this.dispEvent(MoonEvent.CLICK);
        };
        Object.defineProperty(BasicButton.prototype, "textWidth", {
            get: function () {
                return this.text.width + 20;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BasicButton.prototype, "textHeight", {
            get: function () {
                return this.text.height + 20;
            },
            enumerable: true,
            configurable: true
        });
        BasicButton.prototype.setSkinSize = function () {
            if (this.skinAutoScale && this.text.text != "") {
                var scale = this.textWidth / this.statusNormal.width;
                if (this.statusNormal instanceof Bitmap) {
                    this.statusNormal.width = this.textWidth;
                    this.statusDown.width = this.textWidth;
                }
                else {
                    this.statusNormal.scaleX = this.statusDown.scaleX = scale;
                }
                var height = this.textHeight;
                if (height >= this.statusNormal.height) {
                    scale = height / this.statusNormal.height;
                    if (this.statusNormal instanceof Bitmap) {
                        this.statusNormal.height = this.textHeight;
                        this.statusDown.height = this.textHeight;
                    }
                    else {
                        this.statusNormal.scaleY = this.statusDown.scaleY = scale;
                    }
                }
            }
        };
        BasicButton.prototype.setTextPosition = function () {
            this.text.anchorOffsetX = this.text.width >> 1;
            this.text.anchorOffsetY = this.text.height >> 1;
            if (this.textWidth > this.statusNormal.width)
                this.text.x = this.textWidth >> 1;
            else
                this.text.x = this.statusNormal.width >> 1;
            if (this.textHeight > this.statusNormal.height)
                this.text.y = this.textHeight >> 1;
            else
                this.text.y = this.statusNormal.height >> 1;
        };
        BasicButton.prototype.updateSkin = function (skin) {
            this.skinContainer.removeChildren();
            this.skinContainer.addChild(skin);
        };
        BasicButton.prototype.dispose = function () {
            this.close();
            _super.prototype.dispose.call(this);
        };
        return BasicButton;
    }(MoonContainer));
    moon.BasicButton = BasicButton;
    __reflect(BasicButton.prototype, "moon.BasicButton", ["moon.IOnoff"]);
    /**类似多个皮肤按钮,构造函数的参数必须大于2个且必须是2的次方
     * 使用四个皮肤就可以模拟ToggleSwitch了
    */
    var MoreSkinButton = (function (_super) {
        __extends(MoreSkinButton, _super);
        function MoreSkinButton(skins) {
            var _this = _super.call(this, skins[0], skins[1]) || this;
            _this._currentPage = 0;
            _this.skins = skins;
            return _this;
        }
        /**更新到第几个按钮同时刷新皮肤 */
        MoreSkinButton.prototype.updatePage = function (value) {
            this.currentPage = value;
            this.setSkinNormal();
        };
        Object.defineProperty(MoreSkinButton.prototype, "currentPage", {
            get: function () {
                return this._currentPage;
            },
            set: function (value) {
                value = value * 2 == this.skins.length ? 0 : value;
                this._currentPage = value;
                this.statusNormal = this.skins[value * 2];
                this.statusDown = this.skins[(value * 2) + 1];
                this.setSkinSize();
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(MoreSkinButton.prototype, "toggleSwitch", {
            set: function (value) {
                this._toggleSwitch = value;
            },
            enumerable: true,
            configurable: true
        });
        MoreSkinButton.prototype.onTouch = function (e) {
            if (e.type == egret.TouchEvent.TOUCH_END) {
                if (this._toggleSwitch) {
                    this.currentPage = 1 - this.currentPage;
                }
            }
            _super.prototype.onTouch.call(this, e);
        };
        return MoreSkinButton;
    }(BasicButton));
    moon.MoreSkinButton = MoreSkinButton;
    __reflect(MoreSkinButton.prototype, "moon.MoreSkinButton");
    /**基础的组件类*/
    var BasicBar = (function (_super) {
        __extends(BasicBar, _super);
        function BasicBar() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.items = [];
            _this.index = 0;
            return _this;
        }
        BasicBar.prototype.addItem = function (item) {
            this.items.push(item);
        };
        BasicBar.prototype.removeItem = function (item) {
            var index = this.items.indexOf(item);
            if (index >= 0)
                this.items.splice(index, 1);
        };
        BasicBar.prototype.hasItem = function (index) {
            return this.items.length > 0 && (index >= 0 && index < this.items.length);
        };
        BasicBar.prototype.getItem = function (index) {
            return this.items[index];
        };
        BasicBar.prototype.getNextItem = function () {
            return this.items[this.index++];
        };
        BasicBar.prototype.reset = function () {
            this.index = 0;
        };
        BasicBar.prototype.update = function () {
        };
        /**销毁*/
        BasicBar.prototype.dispose = function () {
            this.reset();
            while (this.hasItem(this.index)) {
                var item = this.getItem(this.index);
                this.removeItem(item);
                if (item instanceof MoonContainer) {
                    item.removeFromParent(true);
                }
            }
        };
        return BasicBar;
    }(BasicView));
    moon.BasicBar = BasicBar;
    __reflect(BasicBar.prototype, "moon.BasicBar", ["moon.IItem"]);
    /***进度条 */
    var ProgressBar = (function (_super) {
        __extends(ProgressBar, _super);
        function ProgressBar(bg, value) {
            if (bg === void 0) { bg = null; }
            if (value === void 0) { value = null; }
            var _this = _super.call(this) || this;
            _this._value = 0;
            _this.setSkin(bg, value);
            _this.addChild(_this.skinBg);
            _this.addChild(_this.skinValue);
            _this.text = (new Label).textField;
            _this.addChild(_this.text);
            return _this;
        }
        ProgressBar.prototype.setSkin = function (bg, value) {
            if (bg === void 0) { bg = null; }
            if (value === void 0) { value = null; }
            this.skinBg = bg || Skin.progressBackground;
            this.skinValue = value || Skin.progressValue;
        };
        Object.defineProperty(ProgressBar.prototype, "value", {
            get: function () {
                return this._value;
            },
            /**值只能是0－1之间 */
            set: function (v) {
                v = v < 0 ? 0 : v > 1 ? 1 : v;
                this._value = v;
                this.skinValue.scaleX = v;
            },
            enumerable: true,
            configurable: true
        });
        ProgressBar.prototype.showText = function (v, x, y) {
            if (x === void 0) { x = -1; }
            if (y === void 0) { y = -1; }
            this.text.text = v;
            if (x == -1)
                this.text.x = (this.skinBg.width - this.text.width) >> 1;
            else
                this.text.x = x;
            if (y == -1)
                this.text.y = this.skinBg.height + 5;
            else
                this.text.y = y;
        };
        return ProgressBar;
    }(MoonContainer));
    moon.ProgressBar = ProgressBar;
    __reflect(ProgressBar.prototype, "moon.ProgressBar");
    /***滑动器 */
    var SliderBar = (function (_super) {
        __extends(SliderBar, _super);
        function SliderBar(bg, value, bar) {
            if (bg === void 0) { bg = null; }
            if (value === void 0) { value = null; }
            if (bar === void 0) { bar = null; }
            var _this = _super.call(this, bg, value) || this;
            _this.skinBar = bar || Skin.sliderBar;
            _this.addChild(_this.skinBar);
            _this.skinBar.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onTouch, _this);
            _this.skinBar.touchEnabled = true;
            _this.layout();
            _this.value = 1;
            return _this;
        }
        SliderBar.prototype.setSkin = function (bg, value) {
            if (bg === void 0) { bg = null; }
            if (value === void 0) { value = null; }
            this.skinBg = bg || Skin.sliderBackground;
            this.skinValue = value || Skin.sliderValue;
        };
        SliderBar.prototype.onTouch = function (e) {
            switch (e.type) {
                case egret.TouchEvent.TOUCH_BEGIN:
                    this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                    this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
                    this.dispEvent(MoonEvent.START);
                    break;
                case egret.TouchEvent.TOUCH_MOVE:
                    this.moveDo(e.stageX, e.stageY);
                    this.dispEvent(MoonEvent.MOVE);
                    break;
                case egret.TouchEvent.TOUCH_END:
                    this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                    this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
                    this.dispEvent(MoonEvent.OVER);
                    break;
            }
        };
        SliderBar.prototype.moveDo = function (x, y) {
            var p = this.globalToLocal(x, y);
            var v;
            if (this.type == Const.HORIZONTAL)
                v = p.x / this.skinValue.width;
            else
                v = -p.y / this.skinValue.width;
            this.value = v;
        };
        Object.defineProperty(SliderBar.prototype, "value", {
            get: function () {
                return this._value;
            },
            /**值只能是0－1之间 */
            set: function (v) {
                v = v < 0 ? 0 : v > 1 ? 1 : v;
                this._value = v;
                this.skinValue.scaleX = v;
                if (this.type == Const.HORIZONTAL)
                    this.skinBar.x = this.skinValue.width * v;
                else
                    this.skinBar.y = -this.skinValue.width * v;
            },
            enumerable: true,
            configurable: true
        });
        /**横竖版布局，默认是横版布局 */
        SliderBar.prototype.layout = function (type, interval) {
            if (type === void 0) { type = Const.HORIZONTAL; }
            if (interval === void 0) { interval = 0; }
            this.type = type;
            if (type == Const.VERTICAL) {
                var angle = -90;
                this.skinBar.x = this.skinValue.height >> 1;
            }
            else {
                var angle = 0;
                this.skinBar.y = this.skinValue.height >> 1;
            }
            this.skinBg.rotation = angle;
            this.skinValue.rotation = angle;
        };
        return SliderBar;
    }(ProgressBar));
    moon.SliderBar = SliderBar;
    __reflect(SliderBar.prototype, "moon.SliderBar", ["moon.ILayout"]);
    /***滚动条 */
    var ScrollBar = (function (_super) {
        __extends(ScrollBar, _super);
        function ScrollBar(bar) {
            if (bar === void 0) { bar = null; }
            var _this = _super.call(this) || this;
            _this.skinBar = bar || Skin.scrollBar;
            _this.skinBar.alpha = 0;
            _this.addChild(_this.skinBar);
            _this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onTouch, _this);
            _this.touchEnabled = true;
            _this.startPos = new Point;
            _this.stPos = new Point;
            _this.setSize();
            _this.layout();
            return _this;
        }
        ScrollBar.prototype.onTouch = function (e) {
            switch (e.type) {
                case egret.TouchEvent.TOUCH_BEGIN:
                    this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                    this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
                    this.stPos.x = e.stageX;
                    this.stPos.y = e.stageY;
                    this.startPos.x = e.stageX - this._target.x;
                    this.startPos.y = e.stageY - this._target.y;
                    this.hideShow(1);
                    this.startTime = egret.getTimer();
                    break;
                case egret.TouchEvent.TOUCH_MOVE:
                    this.moveDo(e.stageX, e.stageY);
                    break;
                case egret.TouchEvent.TOUCH_END:
                    this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                    this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
                    this.hideShow(0, 100);
                    this.timeMove(e.stageX, e.stageY);
                    break;
            }
        };
        //缓动动画
        ScrollBar.prototype.timeMove = function (x, y) {
            var time = egret.getTimer() - this.startTime;
            if (time < 500) {
                var target = this._target;
                var maskRect = this.maskRect;
                Tween.removeTweens(target);
                var dx = x - this.stPos.x;
                var dy = y - this.stPos.y;
                var distance = Math.sqrt(dx * dx + dy * dy);
                var value = (distance / time) * 100;
                var tw = Tween.get(target);
                if (this.type == Const.VERTICAL) {
                    var sign = dy > 0 ? 1 : -1;
                    value *= sign;
                    var h = target.y + value;
                    if (h > 0 && target.y + value > 0)
                        h = 0;
                    if (h < 0 && target.y + value < (maskRect.height - target.height))
                        h = maskRect.height - target.height;
                    tw.to({ y: h }, 400, Ease.sineOut).call(this.setBarPos, this);
                }
                else {
                    var sign = dx > 0 ? 1 : -1;
                    value *= sign;
                    var w = target.x + value;
                    if (w > 0 && target.x + value > 0)
                        w = 0;
                    if (w < 0 && target.x + value < (maskRect.width - target.width))
                        w = maskRect.width - target.width;
                    tw.to({ x: w }, 400, Ease.sineOut).call(this.setBarPos, this);
                }
            }
        };
        ScrollBar.prototype.setBarPos = function () {
            if (this.type == Const.VERTICAL)
                this.skinBar.y = -this._target.y / (this._target.height - this.maskRect.height) * (this.maskRect.height - this.skinBar.height);
            else
                this.skinBar.x = -this._target.x / (this._target.width - this.maskRect.width) * (this.maskRect.width - this.skinBar.width);
        };
        ScrollBar.prototype.hideShow = function (alpha, time) {
            if (time === void 0) { time = 1000; }
            Tween.removeTweens(this.skinBar);
            if (alpha == 1) {
                this.skinBar.alpha = 1;
            }
            var tw = Tween.get(this.skinBar);
            tw.to({ alpha: alpha }, time);
        };
        ScrollBar.prototype.moveDo = function (x, y) {
            if (this.type == Const.VERTICAL) {
                this.canMoveY(y);
            }
            else if (this.type == Const.HORIZONTAL) {
                this.canMoveX(x);
            }
        };
        ScrollBar.prototype.canMoveX = function (x) {
            var dis = this.maskRect.width - this._target.width;
            var xx = x - this.startPos.x;
            if (xx > dis && xx < 0) {
                this._target.x = xx;
                this.skinBar.x = -xx / (this._target.width - this.maskRect.width) * (this.maskRect.width - this.skinBar.width);
            }
        };
        ScrollBar.prototype.canMoveY = function (y) {
            var dis = this.maskRect.height - this._target.height;
            var yy = y - this.startPos.y;
            if (yy > dis && yy < 0) {
                this._target.y = yy;
                this.skinBar.y = -yy / (this._target.height - this.maskRect.height) * (this.maskRect.height - this.skinBar.height);
            }
        };
        ScrollBar.prototype.setMask = function () {
            if (this.maskRect != null && this._target != null) {
                this._target.mask = this.maskRect;
            }
        };
        ScrollBar.prototype.setSkinBarPos = function () {
            this.skinBar.x = this.skinBar.y = 0;
            if (this.type == Const.VERTICAL) {
                this.skinBar.x = this.maskRect.width - this.skinBar.width;
            }
            else if (this.type == Const.HORIZONTAL) {
                this.skinBar.y = this.maskRect.height - this.skinBar.height;
            }
        };
        ScrollBar.prototype.layout = function (type, interval) {
            if (type === void 0) { type = Const.VERTICAL; }
            if (interval === void 0) { interval = 0; }
            this.type = type;
            this.setSkinBarPos();
        };
        ScrollBar.prototype.setSize = function (w, h) {
            if (w === void 0) { w = 200; }
            if (h === void 0) { h = 200; }
            this.maskRect = MoonUI.getRect(w, h);
            this.addChild(this.maskRect);
            this.setMask();
            this.setSkinBarPos();
        };
        Object.defineProperty(ScrollBar.prototype, "target", {
            set: function (value) {
                this._target = value;
                this.addChildAt(this._target, 0);
                this.setMask();
            },
            enumerable: true,
            configurable: true
        });
        return ScrollBar;
    }(MoonContainer));
    moon.ScrollBar = ScrollBar;
    __reflect(ScrollBar.prototype, "moon.ScrollBar", ["moon.ILayout"]);
    /**复选框按钮 */
    var CheckBoxBar = (function (_super) {
        __extends(CheckBoxBar, _super);
        function CheckBoxBar() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        CheckBoxBar.prototype.addItemLabel = function (label, item) {
            if (item === void 0) { item = null; }
            if (item == null)
                item = Skin.getCheckBox(label);
            else
                item.label = label;
            this.addItem(item);
        };
        CheckBoxBar.prototype.addItem = function (item) {
            _super.prototype.addItem.call(this, item);
            item.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            this.addChild(item);
        };
        CheckBoxBar.prototype.removeItem = function (item) {
            _super.prototype.removeItem.call(this, item);
            item.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            item.removeFromParent(true);
        };
        CheckBoxBar.prototype.onClick = function (e) {
            var item = e.currentTarget;
            this.dispEvent(moon.MoonEvent.CHANGE);
        };
        /**布局 type类型为横或竖，interval为对象间的间隔*/
        CheckBoxBar.prototype.layout = function (type, interval) {
            if (type === void 0) { type = Const.VERTICAL; }
            if (interval === void 0) { interval = 10; }
            for (var i = 0; i < this.items.length; i++) {
                var item = this.items[i];
                if (type == Const.VERTICAL)
                    item.y = (item.height + interval) * i;
                else
                    item.x = (item.width + interval) * i;
            }
        };
        Object.defineProperty(CheckBoxBar.prototype, "selectIndexs", {
            get: function () {
                var nums = [];
                for (var i = 0; i < this.items.length; i++) {
                    var btn = this.items[i];
                    if (btn.currentPage == 1)
                        nums.push(i);
                }
                return nums;
            },
            enumerable: true,
            configurable: true
        });
        return CheckBoxBar;
    }(BasicBar));
    moon.CheckBoxBar = CheckBoxBar;
    __reflect(CheckBoxBar.prototype, "moon.CheckBoxBar", ["moon.ILayout"]);
    /**复选框按钮 */
    var TabbarBar = (function (_super) {
        __extends(TabbarBar, _super);
        function TabbarBar() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this._selectIndex = 0;
            return _this;
        }
        TabbarBar.prototype.onClick = function (e) {
            var curr = e.currentTarget;
            this.selectItem(curr);
        };
        TabbarBar.prototype.selectItem = function (curr) {
            this.reset();
            while (this.hasItem(this.index)) {
                var item = this.getNextItem();
                item.currentPage = 0;
                item.setSkinNormal();
                item.open();
            }
            curr.close();
            curr.currentPage = 1;
            curr.setSkinNormal();
            this._selectIndex = this.items.indexOf(curr);
            this.dispEvent(moon.MoonEvent.CHANGE, this._selectIndex);
        };
        Object.defineProperty(TabbarBar.prototype, "selectIndex", {
            get: function () { return this._selectIndex; },
            set: function (value) { this._selectIndex = value, this.selectItem(this.getItem(value)); },
            enumerable: true,
            configurable: true
        });
        return TabbarBar;
    }(CheckBoxBar));
    moon.TabbarBar = TabbarBar;
    __reflect(TabbarBar.prototype, "moon.TabbarBar");
    /**单选框按钮 */
    var RadioButtonBar = (function (_super) {
        __extends(RadioButtonBar, _super);
        function RadioButtonBar() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.isAutoLayout = false;
            return _this;
        }
        RadioButtonBar.prototype.addItemLabel = function (label, item) {
            if (item === void 0) { item = null; }
            if (item == null)
                item = Skin.getRodatioButton(label);
            else
                item.label = label;
            this.addItem(item);
        };
        RadioButtonBar.prototype.render = function () {
            this.update();
        };
        RadioButtonBar.prototype.update = function () {
            var item;
            if (this.isAutoLayout == true) {
                for (var i = 0; i < this.items.length; i++) {
                    item = this.items[i];
                    item.x = (item.width + 10) * i;
                }
            }
        };
        RadioButtonBar.prototype.onClick = function (e) {
            var item = e.currentTarget;
            this.selectIndex = this.items.indexOf(item);
            this.dispEvent(moon.MoonEvent.CHANGE);
        };
        Object.defineProperty(RadioButtonBar.prototype, "selectIndex", {
            get: function () {
                return this._selectIndex;
            },
            set: function (index) {
                this._selectIndex = index;
                var item = this.items[index];
                this.items.map(setSkinNormal, this);
                function setSkinNormal(i) {
                    i.setSkinNormal();
                }
                item.setSkinDown();
            },
            enumerable: true,
            configurable: true
        });
        return RadioButtonBar;
    }(CheckBoxBar));
    moon.RadioButtonBar = RadioButtonBar;
    __reflect(RadioButtonBar.prototype, "moon.RadioButtonBar");
    /**提示警告框 手动关闭*/
    var AlertBar = (function (_super) {
        __extends(AlertBar, _super);
        function AlertBar(title) {
            if (title === void 0) { title = "提示或警告"; }
            var _this = _super.call(this) || this;
            _this.bgColor = Color.black;
            _this.text = (new Label).textField;
            _this.text.text = title;
            return _this;
        }
        /**加载到舞台之后调用 */
        AlertBar.prototype.render = function () {
            _super.prototype.render.call(this);
            this.initView();
        };
        AlertBar.prototype.initView = function () {
            var node = this.createBackground(0, 0.3);
            var tw = this.text.width;
            var th = this.text.height;
            var w = tw + 80;
            var h = th + 120;
            var x = (this.stageWidth - w) >> 1;
            var y = (this.stageHeight - h) >> 1;
            this.bg = new MoonDisplayObject;
            this.bg.type = Const.SHAPE_RECT_ROUND;
            this.bg.data = { w: w, h: h, c: this.bgColor, ew: 10, eh: 10 };
            this.bg.setBackground(0, 2);
            this.bg.x = x;
            this.bg.y = y;
            this.addChild(this.bg);
            var btn = new BasicButton;
            btn.label = "确 定";
            this.bg.addChild(btn);
            btn.x = (w - btn.width) >> 1;
            btn.y = this.text.y + th + 40;
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            this.text.x = x + ((w - tw) >> 1);
            this.text.y = y + 20;
            this.addChild(this.text);
        };
        AlertBar.prototype.onClick = function (e) {
            this.removeFromParent(true);
            this.dispEvent(MoonEvent.CLOSE);
        };
        Object.defineProperty(AlertBar.prototype, "color", {
            /**设置背景色 */
            set: function (value) {
                this.bgColor = value;
                if (this.bg)
                    this.bg.color = value;
            },
            enumerable: true,
            configurable: true
        });
        ;
        AlertBar.prototype.dispose = function () {
            _super.prototype.dispose.call(this);
            this.bg = null;
            this.bgColor = null;
            this.text = null;
        };
        return AlertBar;
    }(BasicBar));
    moon.AlertBar = AlertBar;
    __reflect(AlertBar.prototype, "moon.AlertBar");
    /**提示警告框 自动关闭*/
    var AlertAutoBar = (function (_super) {
        __extends(AlertAutoBar, _super);
        function AlertAutoBar(title, closeTime) {
            if (title === void 0) { title = "提示或警告"; }
            if (closeTime === void 0) { closeTime = 3; }
            var _this = _super.call(this, title) || this;
            _this.time = closeTime;
            return _this;
        }
        AlertAutoBar.prototype.initView = function () {
            var tw = this.text.width;
            var th = this.text.height;
            var w = tw + 20;
            var h = th + 20;
            var x = (this.stageWidth - w) >> 1;
            var y = (this.stageHeight - h) >> 1;
            this.bg = new MoonDisplayObject;
            this.bg.type = Const.SHAPE_RECT_ROUND;
            this.bg.data = { w: w, h: h, c: this.bgColor, ew: 10, eh: 10 };
            this.bg.setBackground(0, 2);
            this.bg.x = x;
            this.bg.y = y;
            this.addChild(this.bg);
            this.text.x = x + ((w - tw) >> 1);
            this.text.y = y + ((h - th) >> 1);
            this.addChild(this.text);
            this.alpha = 0;
            var ty = this.y - 50;
            Tween.get(this).to({ alpha: 1 }, 500).wait(this.time * 1000).to({ alpha: 0, y: ty }, 500).call(this.backCall, this);
        };
        AlertAutoBar.prototype.backCall = function () {
            Tween.removeTweens(this);
            this.removeFromParent(true);
            this.time = null;
            this.dispEvent(MoonEvent.CLOSE);
        };
        return AlertAutoBar;
    }(AlertBar));
    moon.AlertAutoBar = AlertAutoBar;
    __reflect(AlertAutoBar.prototype, "moon.AlertAutoBar");
    /**提示警告框 滚动显示*/
    var AlertRollBar = (function (_super) {
        __extends(AlertRollBar, _super);
        function AlertRollBar(title, bgWidth) {
            if (title === void 0) { title = "提示或警告"; }
            if (bgWidth === void 0) { bgWidth = 200; }
            var _this = _super.call(this, title) || this;
            _this.bgWidth = bgWidth;
            return _this;
        }
        AlertRollBar.prototype.initView = function () {
            var tw = this.text.width;
            var th = this.text.height;
            var w = this.bgWidth;
            var h = th + 20;
            var x = (this.stageWidth - w) >> 1;
            var y = 100;
            this.bg = new MoonDisplayObject;
            this.bg.type = Const.SHAPE_RECT;
            this.bg.data = { w: w, h: h, c: this.bgColor };
            this.bg.x = x;
            this.bg.y = y;
            this.addChild(this.bg);
            var mask = MoonUI.getRect(w, h, 0, x, y);
            this.bg.mask = mask;
            this.text.x = w;
            this.text.y = 10;
            this.bg.addChild(this.text);
            var time = 2000 + this.text.text.length * 100;
            var tx = -tw;
            Tween.get(this.text).to({ x: tx }, time).call(this.backCall, this);
        };
        AlertRollBar.prototype.backCall = function () {
            Tween.removeTweens(this);
            Tween.removeTweens(this.text);
            this.removeFromParent(true);
            this.bgWidth = null;
            this.dispEvent(MoonEvent.CLOSE);
        };
        return AlertRollBar;
    }(AlertBar));
    moon.AlertRollBar = AlertRollBar;
    __reflect(AlertRollBar.prototype, "moon.AlertRollBar");
    /**输入框 */
    var InputBar = (function (_super) {
        __extends(InputBar, _super);
        function InputBar(width, height) {
            if (width === void 0) { width = 100; }
            if (height === void 0) { height = 50; }
            var _this = _super.call(this) || this;
            _this.text = (new Label).textField;
            _this.inputW = width;
            _this.inputH = height;
            return _this;
        }
        /**加载到舞台之后调用 */
        InputBar.prototype.render = function () {
            _super.prototype.render.call(this);
            var w = this.inputW;
            var h = this.inputH;
            this.bg = new MoonDisplayObject;
            this.bg.type = Const.SHAPE_RECT_ROUND;
            this.bg.data = { w: w, h: h, c: this.bgColor, ew: 10, eh: 10 };
            this.bg.setBackground(0, 2);
            this.addChild(this.bg);
            var side = 5;
            this.text.x = side;
            this.text.y = side;
            this.text.width = w - side * 2;
            this.text.height = h - side * 2;
            this.text.type = egret.TextFieldType.INPUT;
            this.addChild(this.text);
        };
        /**设置为多行 */
        InputBar.prototype.setMultiline = function () {
            this.text.wordWrap = true;
            this.text.multiline = true;
            this.text.verticalAlign = egret.VerticalAlign.TOP;
        };
        Object.defineProperty(InputBar.prototype, "color", {
            /**设置背景色 */
            set: function (value) {
                this.bgColor = value;
                if (this.bg)
                    this.bg.color = value;
            },
            enumerable: true,
            configurable: true
        });
        ;
        Object.defineProperty(InputBar.prototype, "maxChars", {
            /**设置最大数量 */
            set: function (value) { this.text.maxChars = value; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(InputBar.prototype, "restrict", {
            /**设置输入内容限制（如只输入字母数字 a-zA-Z0-9） */
            set: function (value) { this.text.restrict = value; },
            enumerable: true,
            configurable: true
        });
        return InputBar;
    }(BasicBar));
    moon.InputBar = InputBar;
    __reflect(InputBar.prototype, "moon.InputBar");
    /**面板 */
    var PanelBar = (function (_super) {
        __extends(PanelBar, _super);
        function PanelBar(pWidth, pHeight) {
            if (pWidth === void 0) { pWidth = 0; }
            if (pHeight === void 0) { pHeight = 0; }
            var _this = _super.call(this) || this;
            _this.titleHeight = 60;
            _this.pWidth = pWidth;
            _this.pHeight = pWidth;
            _this.titleBg = new Sprite;
            _this.containerBg = new Sprite;
            _this.title = (new Label).textField;
            _this.container = new MoonContainer;
            return _this;
        }
        /**加载到舞台之后调用 */
        PanelBar.prototype.render = function () {
            if (this.pWidth == 0 && this.pWidth == 0) {
                _super.prototype.render.call(this);
            }
            else {
                this.stageWidth = this.pWidth;
                this.stageHeight = this.pHeight;
            }
            this.createRectBySprite(this.titleBg, this.stageWidth, this.titleHeight, moon.Color.titleBackground);
            this.createRectBySprite(this.containerBg, this.stageWidth, this.stageHeight - this.titleHeight, moon.Color.white, 0, this.titleHeight);
            this.addChild(this.titleBg);
            this.addChild(this.containerBg);
            this.title.anchorOffsetX = this.title.textWidth >> 1;
            this.title.anchorOffsetY = this.title.textHeight >> 1;
            this.title.x = this.stageWidth >> 1;
            this.title.y = this.titleHeight >> 1;
            this.addChild(this.title);
            this.container.y = this.titleHeight;
            this.addChild(this.container);
            this.containerMask = this.createRect(this.stageWidth, this.stageHeight - this.titleHeight, moon.Color.white, 0, this.titleHeight);
            this.container.mask = this.containerMask;
            this.touchEnabled = true; //为了阻挡面板下所有事件
            this.dispEvent(MoonEvent.RENDER_COMPLETE);
        };
        PanelBar.prototype.addItem = function (item, x, y) {
            if (x === void 0) { x = 0; }
            if (y === void 0) { y = 0; }
            _super.prototype.addItem.call(this, item);
            if (x != 0)
                item.x = x;
            if (y != 0)
                item.y = y;
            this.container.addChild(item);
        };
        PanelBar.prototype.removeItem = function (item) {
            _super.prototype.removeItem.call(this, item);
            if (this.container.contains(item))
                this.container.removeChild(item);
        };
        Object.defineProperty(PanelBar.prototype, "label", {
            get: function () {
                return this.title.text;
            },
            set: function (value) {
                this.title.text = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PanelBar.prototype, "colorTop", {
            set: function (c) {
                var w = this.titleBg.width, h = this.titleBg.height;
                this.createRectBySprite(this.titleBg, w, h, c);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PanelBar.prototype, "colorBottom", {
            set: function (c) {
                var w = this.containerBg.width, h = this.containerBg.height;
                this.createRectBySprite(this.containerBg, w, h, c, 0, this.titleHeight);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PanelBar.prototype, "windowRect", {
            get: function () {
                var rect = new Rectangle(0, 0, this.stageWidth, this.stageHeight);
                return rect;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PanelBar.prototype, "topHeight", {
            get: function () {
                return this.titleHeight;
            },
            enumerable: true,
            configurable: true
        });
        PanelBar.prototype.removeAll = function () {
            this.container.dispose();
        };
        return PanelBar;
    }(BasicBar));
    moon.PanelBar = PanelBar;
    __reflect(PanelBar.prototype, "moon.PanelBar");
    /**多个面板管理 */
    var PanelMoreManager = (function (_super) {
        __extends(PanelMoreManager, _super);
        function PanelMoreManager() {
            var _this = _super.call(this) || this;
            _this.radioButton = new RadioButtonBar;
            _this.currentPage = 0;
            _this.posStartX = 0;
            _this.moveItems = [];
            _this.container = new MoonContainer;
            _this.addChild(_this.container);
            _this.radioButton.isAutoLayout = true;
            return _this;
        }
        PanelMoreManager.prototype.open = function () {
            this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
        };
        PanelMoreManager.prototype.close = function () {
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
        };
        PanelMoreManager.prototype.update = function () {
            this.container.removeChildren();
            var itemW;
            var itemH;
            if (this.items.length > 0) {
                var item = this.items[0];
                this.container.addChild(item);
                itemW = item.windowRect.width;
                itemH = item.windowRect.height;
                this.panelWidth = itemW;
            }
            var len = this.items.length;
            for (var i = 0; i < len; i++) {
                var btn = new BasicButton(moon.Skin.pointNormal, moon.Skin.pointDown);
                this.radioButton.addItem(btn);
            }
            btn = this.radioButton.getItem(0);
            btn.setSkinDown();
            this.radioButton.x = (itemW - len * 22) >> 1;
            this.radioButton.y = itemH - 20;
            this.addChild(this.radioButton);
        };
        PanelMoreManager.prototype.render = function () {
            this.update();
            if (this.items.length > 1) {
                this.open();
            }
        };
        PanelMoreManager.prototype.onTouch = function (e) {
            switch (e.type) {
                case egret.TouchEvent.TOUCH_BEGIN:
                    this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                    this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
                    this.posStartX = e.stageX;
                    this.dispEvent(MoonEvent.START);
                    break;
                case egret.TouchEvent.TOUCH_MOVE:
                    this.moveDo(e.stageX);
                    break;
                case egret.TouchEvent.TOUCH_END:
                    this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
                    this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
                    this.moveEnd(e.stageX);
                    break;
            }
        };
        PanelMoreManager.prototype.moveDo = function (x) {
            var disx = x - this.posStartX;
            if (Math.abs(disx) > 20) {
                if (this.moveItems.length == 0) {
                    var item = this.items[this.currentPage];
                    var width = this.panelWidth;
                    this.moveItems.push(item);
                    if (this.currentPage == 0) {
                        item = this.items[this.currentPage + 1];
                        this.container.addChild(item);
                        item.x = width;
                        this.moveItems.push(item);
                    }
                    else if (this.currentPage == this.items.length - 1) {
                        item = this.items[this.currentPage - 1];
                        this.container.addChild(item);
                        item.x = -width;
                        this.moveItems.push(item);
                    }
                    else {
                        item = this.items[this.currentPage - 1];
                        this.container.addChild(item);
                        item.x = -width;
                        this.moveItems.push(item);
                        item = this.items[this.currentPage + 1];
                        this.container.addChild(item);
                        item.x = width;
                        this.moveItems.push(item);
                    }
                }
                var boo1 = (this.currentPage == 0 && disx > 0);
                var boo2 = ((this.currentPage == this.items.length - 1) && disx < 0);
                if (!boo1 && !boo2) {
                    this.container.x = disx;
                }
            }
        };
        PanelMoreManager.prototype.moveEnd = function (x) {
            if (this.container.x == 0) {
                this.backCall(0);
                return;
            }
            var disx = x - this.posStartX;
            var tw = egret.Tween.get(this.container);
            var currX = this.panelWidth;
            var turnDis = this.panelWidth >> 2;
            //至少滑动窗口宽的四分之一才可以算翻页
            if (Math.abs(disx) > turnDis) {
                currX = this.panelWidth;
                currX *= disx > 0 ? 1 : -1;
            }
            else {
                disx = 0;
                currX = 0;
            }
            var time = 200;
            tw.to({ x: currX }, time);
            tw.call(this.backCall, this, [disx]);
        };
        /**结束翻页后的回调函数 */
        PanelMoreManager.prototype.backCall = function (disx) {
            if (disx > 0) {
                this.currentPage--;
                this.currentPage = this.currentPage < 0 ? 0 : this.currentPage;
            }
            else if (disx < 0) {
                this.currentPage++;
                this.currentPage = this.currentPage == this.items.length ? this.items.length - 1 : this.currentPage;
            }
            this.container.removeChildren();
            var item = this.items[this.currentPage];
            item.x = 0;
            this.container.addChild(item);
            this.radioButton.selectIndex = this.currentPage;
            this.moveItems.length = 0;
            this.container.x = 0;
            this.dispEvent(MoonEvent.OVER);
        };
        /**销毁*/
        PanelMoreManager.prototype.dispose = function () {
            _super.prototype.dispose.call(this);
            this.close();
        };
        return PanelMoreManager;
    }(BasicBar));
    moon.PanelMoreManager = PanelMoreManager;
    __reflect(PanelMoreManager.prototype, "moon.PanelMoreManager", ["moon.IOnoff"]);
    var GameData = (function () {
        function GameData() {
        }
        /**游戏屏幕宽 */
        GameData.stageWidth = 640;
        /**游戏屏幕高 */
        GameData.stageHeight = 1136;
        /**帧频*/
        GameData.FPS = 60;
        /**游戏版号，默认是调试版 */
        GameData.version = Const.VER_DEBUG;
        /**是否为移动模式（例如移动电话或平板电脑） */
        GameData.isMobile = egret.Capabilities.isMobile;
        /**游戏的ID */
        GameData.gameId = 1;
        /**游戏分数 */
        GameData.score = 0;
        /**游戏历史分数 */
        GameData.scoreHighest = 0;
        return GameData;
    }());
    moon.GameData = GameData;
    __reflect(GameData.prototype, "moon.GameData");
    /**游戏加载模版 */
    var GameLoad = (function (_super) {
        __extends(GameLoad, _super);
        function GameLoad() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.color = 0XF9AB03;
            return _this;
        }
        GameLoad.prototype.render = function () {
            _super.prototype.render.call(this);
            this.createBgGradientFill();
            var container = new Sprite;
            this.addChild(container);
            var sw = this.stageWidth;
            var sh = this.stageHeight;
            var w = 80;
            var loadbg = MoonUI.getRoundRect(sw - 100, w, 0XFCE59D, 10, 10);
            loadbg.x = (sw - loadbg.width) >> 1;
            loadbg.y = (sh - loadbg.height) >> 1;
            container.addChild(loadbg);
            //--------
            var progress = MoonUI.getRect(sw - 120, w - 10, this.color);
            progress.x = (sw - progress.width) >> 1;
            progress.y = (sh - progress.height) >> 1;
            container.addChild(progress);
            this.proWidth = progress.width;
            var mask = MoonUI.getRoundRect(sw - 120, w - 10, 0, 10, 10);
            mask.x = (sw - mask.width) >> 1;
            mask.y = (sh - mask.height) >> 1;
            progress.mask = mask;
            this.progress = progress;
            //--------
            var txtbg = new MoonDisplayObject();
            txtbg.type = moon.Const.SHAPE_CIRCLE;
            txtbg.data = { r: w / 2, c: 0XE18E0D };
            txtbg.setBackground(0XFFFFFF, 5);
            this.addChild(txtbg);
            txtbg.x = loadbg.x + loadbg.width - w / 2;
            txtbg.y = loadbg.y + w / 2;
            this.txtLoadPos = new Point(txtbg.x, txtbg.y);
            var txtExp = this.createText(0, 0, "");
            txtExp.size = 40;
            txtExp.textColor = 0xB07300;
            this.txtLoad = txtExp;
            //--------
            var txtTip = this.createText(0, 0, "游戏加载");
            txtTip.size = 40;
            txtTip.x = (sw - txtTip.width) >> 1;
            txtTip.y = loadbg.y - txtTip.height * 2;
            var txtName = this.createText(0, 0, "");
            txtName.size = 40;
            this.txtName = txtName;
            this.updateName("敬请期待");
            //--------
            this.createAirFan();
            this.airFan.x = txtbg.x;
            this.airFan.y = txtbg.y;
            this.createLogo();
            this.update(0);
            this.play();
        };
        GameLoad.prototype.loop = function (n) {
            this.airFan.rotation += 3;
            return true;
        };
        GameLoad.prototype.createAirFan = function () {
            this.airFan = new Sprite;
            this.addChild(this.airFan);
            for (var i = 0; i < 4; i++) {
                var shape = new Sprite();
                this.airFan.addChild(shape);
                shape.graphics.lineStyle(0);
                shape.graphics.beginFill(0xFFFFFF);
                shape.graphics.cubicCurveTo(-29, -28, 29, -28, 0, 0);
                shape.graphics.endFill();
                shape.rotation = i * 90;
            }
        };
        GameLoad.prototype.createLogo = function () {
            var sw = this.stageWidth;
            var sh = this.stageHeight;
            var logo = new MoonDisplayObject();
            logo.type = moon.Const.SHAPE_CIRCLE;
            logo.data = { r: 50, c: 0XE18E0D };
            logo.setBackground(0XFFFFFF, 2);
            logo.x = sw >> 1;
            logo.y = logo.height;
            this.addChild(logo);
            var txtName = this.createText(0, 0, "ZL");
            txtName.size = 40;
            txtName.x = logo.x - (txtName.width >> 1);
            txtName.y = logo.y - (txtName.height >> 1) - 15;
            txtName = this.createText(0, 0, "game");
            txtName.size = 30;
            txtName.x = logo.x - (txtName.width >> 1);
            txtName.y = logo.y - (txtName.height >> 1) + 15;
            this.addChild(moon.MoonUI.getHeart(15, 0XFFFFFF));
            txtName = this.createText(0, 0, "子乐游戏");
            txtName.size = 40;
            txtName.textColor = 0XE09F21;
            txtName.x = sw - txtName.width - 10;
            txtName.y = sh - txtName.height - 10;
        };
        /**创建渐变色背景 */
        GameLoad.prototype.createBgGradientFill = function (c1, c2) {
            if (c1 === void 0) { c1 = 0XFDD559; }
            if (c2 === void 0) { c2 = 0XE09F21; }
            var w = this.stageWidth;
            var h = this.stageHeight;
            var matrix = new egret.Matrix();
            matrix.createGradientBox(w * 2, h * 2, Math.PI / 2);
            var sprite = new Sprite;
            sprite.graphics.beginGradientFill(egret.GradientType.RADIAL, [c1, c2], [1, 1], [0, 255], matrix);
            sprite.graphics.drawRect(0, 0, w, h);
            this.addChild(sprite);
            return sprite;
        };
        GameLoad.prototype.updateName = function (name) {
            this.txtName.text = name;
            this.txtName.x = (this.stageWidth - this.txtName.width) >> 1;
            this.txtName.y = this.stageHeight / 2 + this.txtName.height * 2;
        };
        GameLoad.prototype.update = function (value) {
            if (value > 1)
                return;
            if (value > 0.99)
                this.stop();
            this.progress.scaleX = value;
            var txtExp = this.txtLoad;
            var pos = this.txtLoadPos;
            txtExp.text = Math.ceil(value * 100) + "%";
            txtExp.x = (this.stageWidth - txtExp.width) >> 1;
            txtExp.y = pos.y - txtExp.height / 2;
            var exp = MoonUI.getCircle(5 + Math.random() * 5, this.color, pos.x, pos.y);
            exp.y = 10 - Math.random() * 20;
            this.addChildAt(exp, 2);
            Tween.get(exp).to({ x: -this.proWidth, alpha: 0 }, 1000);
        };
        return GameLoad;
    }(moon.GameView));
    moon.GameLoad = GameLoad;
    __reflect(GameLoad.prototype, "moon.GameLoad");
})(moon || (moon = {}));
//子弹基础类
//1.生成子弹图片
//2.更换子弹的刚体
//3.负责子弹的移动，或者给力
//4.负责子弹的停止
var py2Obj;
(function (py2Obj) {
    var basicObj = (function () {
        function basicObj(world, gamePanle, romveSkins) {
            this.m_removeSkins = []; //需要删除刚体的皮肤
            this.m_num = 5;
            this.m_world = world;
            this.m_gamePanle = gamePanle;
            this.m_removeSkins = romveSkins;
        }
        basicObj.prototype.getBody = function () {
            return this.m_body;
        };
        /**设置初始化 */
        basicObj.prototype.init = function () {
            this.m_body = this.createMyRigidbody();
        };
        /**设置材质 */
        basicObj.prototype.setMaterial = function (material) {
            this.m_body.shapes[0].material = material;
            var roleAndStoneMaterial = new p2.ContactMaterial(material, material, { restitution: 0.7, friction: 0 }); //弹性，摩擦力
            this.m_world.p2World.addContactMaterial(roleAndStoneMaterial);
        };
        /**设置位置 */
        basicObj.prototype.setPostion = function (x, y) {
            this.m_body.position = [x, y];
        };
        /**设置冲量 */
        basicObj.prototype.setBallImpulse = function () {
            var x = Math.random() > 0.5 ? -5000 : 5000;
            var y = -5000 - (Math.random() * 2000);
            this.setForce(x, y);
        };
        /**设置力 */
        basicObj.prototype.setForce = function (x, y) {
            this.m_body.fixedX = false;
            this.m_body.fixedY = false;
            this.m_body.applyImpulse([x, y], [0, 0]);
        };
        /** 创建皮肤*/
        basicObj.prototype.createSkin = function (name) {
            var skin = new NumImage(name);
            skin.x = -500; //避免在一出现的时候会在左上角闪现
            skin.setAnchorCenter();
            this.m_gamePanle.addChild(skin);
            return skin;
        };
        /**固定我们的球 */
        basicObj.prototype.fixObj = function () {
            this.m_body.fixedX = true;
            this.m_body.fixedY = true;
        };
        basicObj.prototype.remove = function () {
            //this.m_removeSkins.push(this.m_body.userData.skin);
            this.m_world.removeBodys.push(this.m_body);
        };
        /** 创建球刚体*/
        basicObj.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("ball_png");
            var body = world.createCircleBodyShape(skin.width >> 1);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            return body;
        };
        basicObj.prototype.removebullet = function (ba) {
            this.m_world.removeBodys.push(ba.getBody());
            //this.m_removeSkins.push(ba.getBody().userData.skin);
        };
        basicObj.prototype.getCollision = function (otherBody) {
        };
        return basicObj;
    }());
    py2Obj.basicObj = basicObj;
    __reflect(basicObj.prototype, "py2Obj.basicObj");
})(py2Obj || (py2Obj = {}));
var MOON_FTP = 24;
var moon;
(function (moon) {
    /**图像类 */
    var Image = (function (_super) {
        __extends(Image, _super);
        function Image(skinName) {
            if (skinName === void 0) { skinName = ""; }
            var _this = _super.call(this) || this;
            if (skinName != "") {
                _this.skinName = skinName;
                _this.position = new Point();
                _this.addBitmap();
                _this.bgWidth = _this.width;
                _this.bgHeight = _this.height;
            }
            return _this;
        }
        Image.prototype.addBitmap = function () {
            if (RES.hasRes(this.skinName)) {
                this.skinImage = new moon.Scale9Image(this.skinName);
                this.skinImage.smoothing = true;
                this.addChild(this.skinImage);
            }
            else {
                trace("找不到资源：" + this.skinName);
                //egret.error("找不到key"+this.skinName);
            }
        };
        /**设置锚点在中心 */
        Image.prototype.setAnchorCenter = function () {
            this.anchorOffsetX = this.width >> 1;
            this.anchorOffsetY = this.height >> 1;
        };
        return Image;
    }(moon.MoonContainer));
    moon.Image = Image;
    __reflect(Image.prototype, "moon.Image");
    /**图像容器类 */
    var BasicContainer = (function (_super) {
        __extends(BasicContainer, _super);
        function BasicContainer() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.items = [];
            _this.index = 0;
            return _this;
        }
        BasicContainer.prototype.addItem = function (item) {
            this.items.push(item);
        };
        BasicContainer.prototype.removeItem = function (index) {
            if (this.hasItem(index)) {
                this.items.splice(index, 1);
            }
        };
        BasicContainer.prototype.getItem = function (index) {
            return this.items[index];
        };
        BasicContainer.prototype.hasItem = function (index) {
            return this.items.length > 0 && (index >= 0 && index < this.items.length);
        };
        BasicContainer.prototype.getNextItem = function () {
            return this.items[this.index++];
        };
        BasicContainer.prototype.reset = function () {
            this.index = 0;
        };
        return BasicContainer;
    }(Image));
    moon.BasicContainer = BasicContainer;
    __reflect(BasicContainer.prototype, "moon.BasicContainer");
    /**图像贴图类 */
    var ImageChartlet = (function (_super) {
        __extends(ImageChartlet, _super);
        function ImageChartlet(skinName, count) {
            if (count === void 0) { count = 1; }
            var _this = _super.call(this) || this;
            _this.skinName = skinName;
            for (var i = 0; i < count; i++) {
                _this.items.push(_this.getBitmap());
            }
            return _this;
        }
        ImageChartlet.prototype.getBitmap = function () {
            var skin;
            if (RES.hasRes(this.skinName)) {
                skin = new moon.Scale9Image(this.skinName);
                this.addChild(skin);
            }
            else {
                trace("找不到资源：" + this.skinName);
            }
            return skin;
        };
        /**竖排获横排 */
        ImageChartlet.prototype.layout = function (type, interval) {
            if (interval === void 0) { interval = 0; }
            if (type == moon.Const.VERTICAL)
                moon.SimpleLayout.displayRank(this.items, 1, interval, interval, 0, 0);
            else if (type == moon.Const.HORIZONTAL)
                moon.SimpleLayout.displayRank(this.items, this.items.length, interval, interval, 0, 0);
        };
        /**多行排列，xNum是一排排几个 */
        ImageChartlet.prototype.setMultiLine = function (xNum, interval) {
            if (interval === void 0) { interval = 0; }
            moon.SimpleLayout.displayRank(this.items, xNum, interval, interval, 0, 0);
        };
        return ImageChartlet;
    }(BasicContainer));
    moon.ImageChartlet = ImageChartlet;
    __reflect(ImageChartlet.prototype, "moon.ImageChartlet", ["moon.ILayout"]);
    /**图像动画类 */
    var ImageAnimation = (function (_super) {
        __extends(ImageAnimation, _super);
        function ImageAnimation(skinName, start, end, type) {
            if (skinName === void 0) { skinName = ""; }
            if (type === void 0) { type = "png"; }
            var _this = _super.call(this) || this;
            _this._ftp = MOON_FTP;
            for (var i = start; i <= end; i++) {
                _this.items.push(skinName + i + "_" + type);
            }
            _this.skinName = _this.getItem(0);
            _this.addBitmap();
            _this.createTime();
            return _this;
        }
        ImageAnimation.prototype.createTime = function () {
            if (this.timer == null) {
                this.timer = new egret.Timer(1000 / this.ftp, 0);
                this.timer.addEventListener(egret.TimerEvent.TIMER, this.onTimer, this);
            }
        };
        ImageAnimation.prototype.onTimer = function () {
            if (this.hasItem(++this.index)) {
                this.gotoAndStop(this.index);
            }
            else {
                if (this.loop) {
                    this.reset();
                    this.gotoAndStop(this.index);
                }
                else {
                    this.timer.stop();
                }
            }
        };
        ImageAnimation.prototype.gotoAndStop = function (index) {
            if (this.hasItem(index)) {
                this.index = index;
                this.skinName = this.getItem(index);
                this.update();
            }
            else {
                trace("gotoAndStop的参数请保持在0到" + this.items.length, "当前index=" + index);
            }
        };
        ImageAnimation.prototype.gotoAndPlay = function (index) {
            this.index = index;
            this.play();
        };
        ImageAnimation.prototype.play = function () {
            this.timer.start();
        };
        ImageAnimation.prototype.stop = function () {
            this.timer.stop();
        };
        ImageAnimation.prototype.update = function () {
            if (RES.hasRes(this.skinName)) {
                this.skinImage.texture = RES.getRes(this.skinName);
            }
            else {
                trace("找不到资源：" + this.skinName);
            }
        };
        Object.defineProperty(ImageAnimation.prototype, "currentFrame", {
            get: function () { return this.index; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ImageAnimation.prototype, "ftp", {
            get: function () { return this._ftp; },
            set: function (value) {
                this._ftp = value;
                this.removeTime();
                this.createTime();
            },
            enumerable: true,
            configurable: true
        });
        ImageAnimation.prototype.removeTime = function () {
            if (this.timer != null) {
                this.timer.stop();
                this.timer.removeEventListener(egret.TimerEvent.TIMER, this.onTimer, this);
                this.timer = null;
            }
        };
        ImageAnimation.prototype.dispose = function () {
            _super.prototype.dispose.call(this);
            this.removeTime();
        };
        return ImageAnimation;
    }(BasicContainer));
    moon.ImageAnimation = ImageAnimation;
    __reflect(ImageAnimation.prototype, "moon.ImageAnimation");
    /**图像布局类 */
    var ImageLayout = (function () {
        function ImageLayout() {
        }
        ImageLayout.getIns = function () {
            if (this.instance == null)
                this.instance = new ImageLayout();
            return this.instance;
        };
        ImageLayout.prototype.setImage = function (image) {
            this.image = image;
        };
        ImageLayout.prototype.setStageWH = function (w, h) {
            this.tw = w;
            this.th = h;
        };
        ImageLayout.prototype.setTop = function (distance) {
            this.image.y = distance;
        };
        ImageLayout.prototype.setBottom = function (distance) {
            this.image.y = this.th - this.image.height - distance;
        };
        ImageLayout.prototype.setLeft = function (distance) {
            this.image.x = distance;
        };
        ImageLayout.prototype.setRight = function (distance) {
            this.image.x = this.tw - this.image.width - distance;
        };
        ImageLayout.prototype.setCenterX = function (distance) {
            if (distance === void 0) { distance = 0; }
            this.image.x = ((this.tw - this.image.width) >> 1) + distance;
        };
        ImageLayout.prototype.setCenterY = function (distance) {
            if (distance === void 0) { distance = 0; }
            this.image.y = ((this.tw - this.image.width) >> 1) + distance;
        };
        ImageLayout.prototype.setCenterXByPanent = function (image) {
            if (image.parent instanceof Image)
                image.x = (image.parent.bgWidth - image.width) >> 1;
            else
                image.x = (image.parent.width - image.width) >> 1;
        };
        ImageLayout.prototype.setCenterYByPanent = function (image) {
            if (image.parent instanceof Image)
                image.y = (image.parent.bgHeight - image.height) >> 1;
            else
                image.y = (image.parent.height - image.height) >> 1;
        };
        return ImageLayout;
    }());
    moon.ImageLayout = ImageLayout;
    __reflect(ImageLayout.prototype, "moon.ImageLayout");
})(moon || (moon = {}));
//子弹基础类(10 开始)
//1.生成子弹图片
//2.更换子弹的刚体
//3.负责子弹的移动，或者给力
//4.负责子弹的停止
var py2Obj;
(function (py2Obj) {
    var basicProp = (function (_super) {
        __extends(basicProp, _super);
        function basicProp(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.objkind = 100;
            return _this;
        }
        basicProp.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        basicProp.prototype.createMyRigidbody = function () {
            return null;
        };
        basicProp.prototype.getCollision = function (otherBody) {
            if (otherBody.objkind == 301) {
                this.m_gamePanle.addPoint(this.m_point);
            }
        };
        return basicProp;
    }(py2Obj.basicObj));
    py2Obj.basicProp = basicProp;
    __reflect(basicProp.prototype, "py2Obj.basicProp");
})(py2Obj || (py2Obj = {}));
var MButton = (function (_super) {
    __extends(MButton, _super);
    function MButton() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return MButton;
}(moon.BasicButton));
__reflect(MButton.prototype, "MButton");
;
var MImage = (function (_super) {
    __extends(MImage, _super);
    function MImage() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return MImage;
}(moon.Image));
__reflect(MImage.prototype, "MImage");
;
var ImageAnimation = (function (_super) {
    __extends(ImageAnimation, _super);
    function ImageAnimation() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return ImageAnimation;
}(moon.ImageAnimation));
__reflect(ImageAnimation.prototype, "ImageAnimation");
;
var Layout = (function (_super) {
    __extends(Layout, _super);
    function Layout() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Layout;
}(moon.ImageLayout));
__reflect(Layout.prototype, "Layout");
;
var Scale9Image = (function (_super) {
    __extends(Scale9Image, _super);
    function Scale9Image() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Scale9Image;
}(moon.Scale9Image));
__reflect(Scale9Image.prototype, "Scale9Image");
;
var MoonEvent = (function (_super) {
    __extends(MoonEvent, _super);
    function MoonEvent() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return MoonEvent;
}(moon.MoonEvent));
__reflect(MoonEvent.prototype, "MoonEvent");
;
var GameData = (function (_super) {
    __extends(GameData, _super);
    function GameData() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return GameData;
}(moon.GameData));
__reflect(GameData.prototype, "GameData");
;
var Const = (function (_super) {
    __extends(Const, _super);
    function Const() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Const;
}(moon.Const));
__reflect(Const.prototype, "Const");
;
var plan = (function (_super) {
    __extends(plan, _super);
    function plan() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return plan;
}(moon.PanelBar));
__reflect(plan.prototype, "plan");
;
var moon;
(function (moon) {
    /**游戏模版 */
    var BasicGameMain = (function (_super) {
        __extends(BasicGameMain, _super);
        function BasicGameMain() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        /**加载到舞台之后调用 */
        BasicGameMain.prototype.render = function () {
            _super.prototype.render.call(this);
            this.initView();
        };
        BasicGameMain.prototype.initView = function () {
            this.createBgGradientFill();
            this.panelGame = new BasicGamePanel;
            this.panelGame.addEvent(moon.MoonEvent.OVER, this.onOver, this);
            this.addChild(this.panelGame);
            this.setBtn = new SetButton;
            this.setBtn.x = 100;
            this.setBtn.y = 100;
            this.setBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.openSetPanel, this);
            this.addChild(this.setBtn);
            this.panelSet = new BasicGameSet;
            this.panelSet.addEvent(moon.MoonEvent.PLAY, this.onSetHandler, this);
            this.panelSet.addEvent(moon.MoonEvent.CHANGE, this.onSetHandler, this);
            this.panelStart = new BasicGameStart;
            this.panelStart.addEvent(moon.MoonEvent.START, this.start, this);
            this.addChild(this.panelStart);
            this.panelOver = new BasicGameOver;
            this.panelOver.addEvent(moon.MoonEvent.START, this.start, this);
        };
        BasicGameMain.prototype.start = function (e) {
            this.panelGame.initGame();
            this.panelGame.start();
        };
        BasicGameMain.prototype.onOver = function (e) {
            this.addChild(this.panelOver);
            this.panelOver.alpha = 0;
            Tween.get(this.panelOver).to({ alpha: 1 }, 300);
            this.panelOver.update(e.data);
        };
        BasicGameMain.prototype.openSetPanel = function (e) {
            this.addChild(this.panelSet);
            this.panelSet.alpha = 0;
            Tween.get(this.panelSet).to({ alpha: 1 }, 300);
            this.panelGame.pause();
        };
        BasicGameMain.prototype.onSetHandler = function (e) {
            if (e.type == moon.MoonEvent.PLAY) {
                this.panelGame.start();
            }
            else {
                var value = e.data;
                if (e.dataType == "soundBg") {
                }
                else if (e.dataType == "soundEffect") {
                }
            }
        };
        return BasicGameMain;
    }(moon.GameView));
    moon.BasicGameMain = BasicGameMain;
    __reflect(BasicGameMain.prototype, "moon.BasicGameMain");
    /**游戏模版 */
    var BasicGamePanel = (function (_super) {
        __extends(BasicGamePanel, _super);
        function BasicGamePanel() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        /**加载到舞台之后调用 */
        BasicGamePanel.prototype.render = function () {
            _super.prototype.render.call(this);
            this.initView();
        };
        BasicGamePanel.prototype.initView = function () {
            this.createBgGradientFill();
            this.txtScore = this.createText();
            this.txtLevel = this.createText(200);
            this.txtBlood = this.createText(400);
            this.initGame();
        };
        BasicGamePanel.prototype.initGame = function () {
            this.level = 1;
            this.score = 0;
            this.blood = 200;
            this.updateBlood();
            this.updateLevel();
            this.updateScore();
        };
        BasicGamePanel.prototype.start = function () {
            this.play();
        };
        BasicGamePanel.prototype.pause = function () {
            this.stop();
        };
        BasicGamePanel.prototype.loop = function (n) {
            this.blood--;
            this.score += 10;
            this.updateScore();
            this.updateBlood();
            return true;
        };
        BasicGamePanel.prototype.over = function () {
            this.dispEvent(moon.MoonEvent.OVER, { score: this.score, level: this.level });
            this.stop();
        };
        BasicGamePanel.prototype.updateLevel = function () {
            this.txtLevel.text = "level:" + this.level;
        };
        BasicGamePanel.prototype.updateScore = function () {
            this.txtScore.text = "score:" + this.score;
            if (this.score > 0 && this.score % 200 == 0) {
                this.level++;
                this.updateLevel();
            }
        };
        BasicGamePanel.prototype.updateBlood = function () {
            this.txtBlood.text = "blood:" + this.blood;
            if (this.blood == 0) {
                this.over();
            }
        };
        BasicGamePanel.prototype.createImageBg = function (name) {
            this.addChild(new MImage(name));
        };
        BasicGamePanel.prototype.dispose = function () {
            this.stop();
            _super.prototype.dispose.call(this);
        };
        return BasicGamePanel;
    }(moon.GameView));
    moon.BasicGamePanel = BasicGamePanel;
    __reflect(BasicGamePanel.prototype, "moon.BasicGamePanel");
    /**游戏开始界面 */
    var BasicGameStart = (function (_super) {
        __extends(BasicGameStart, _super);
        function BasicGameStart() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        /**加载到舞台之后调用 */
        BasicGameStart.prototype.render = function () {
            _super.prototype.render.call(this);
            this.initView();
        };
        BasicGameStart.prototype.initView = function () {
            var bg = this.createBackground();
            bg.alpha = 0.5;
            this.createBtn("开始游戏");
            this.createTitle("游戏标题");
        };
        BasicGameStart.prototype.createBtn = function (value) {
            var btn = this.createButton(value);
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            btn.x = (this.stageWidth - btn.width) >> 1;
            btn.y = (this.stageHeight - btn.height) >> 1;
            return btn;
        };
        BasicGameStart.prototype.createTitle = function (value) {
            var title = this.createText(0, 0, value);
            title.x = (this.stageWidth - title.width) / 2;
            title.y = (this.stageHeight - title.height) / 2 - 100;
            return title;
        };
        BasicGameStart.prototype.onClick = function (e) {
            GameControl.GameControlSole.bei.visible = false;
            this.dispEvent(moon.MoonEvent.START);
            Tween.get(this).to({ alpha: 0 }, 300).call(this.backCall, this);
        };
        BasicGameStart.prototype.backCall = function (e) {
            this.removeFromParent();
            /*新手指导*/
            //GameControl.GameControlSole.Upgrade1();
            // GameControl.GameControlSole.newtext();
            //GameControl.GameControlSole.newtext1();
            //  GameControl.GameControlSole.NewGuidebool=true;
            // if(!GameControl.GameControlSole.NewGuidebool)
            // {
            //     GameControl.GameControlSole.newtext();
            // }
            // if(GameControl.GameControlSole.NewGuidebool)
            // {
            //   // GameControl.GameControlSole.newtext()
            //       GameControl.GameControlSole.newtext1();
            // }
        };
        BasicGameStart.prototype.createImageBg = function (name) {
            this.addChild(new MImage(name));
        };
        BasicGameStart.prototype.dianji = function (e) {
            //console.log("paihangbang");
            GameControl.GameControlSole.setGameHandle(this);
            GameControl.GameControlSole.paihangBtnClick();
        };
        return BasicGameStart;
    }(moon.GameView));
    moon.BasicGameStart = BasicGameStart;
    __reflect(BasicGameStart.prototype, "moon.BasicGameStart");
    /**游戏结束界面 */
    var BasicGameOver = (function (_super) {
        __extends(BasicGameOver, _super);
        function BasicGameOver() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        BasicGameOver.prototype.initView = function () {
            var bg = this.createBackground();
            bg.alpha = 0.5;
            this.btnRestart = this.createBtn("再来一次");
            this.btnRank = this.createBtn("排行榜");
            this.btnRank.y += 100;
            this.txtScore = this.createText();
            this.txtLevel = this.createText();
            this.rankPanel = new BasicGameRank;
        };
        BasicGameOver.prototype.update = function (data) {
            this.txtScore.text = "score:" + data["score"];
            this.txtLevel.text = "level:" + data["level"];
            this.txtScore.x = (this.stageWidth - this.txtScore.width) / 2;
            this.txtLevel.x = (this.stageWidth - this.txtLevel.width) / 2;
            this.txtScore.y = (this.stageHeight - this.txtScore.height) / 2 - 60;
            this.txtLevel.y = this.txtScore.y - 60;
            moon.GameData.score = data["score"];
        };
        BasicGameOver.prototype.onClick = function (e) {
            var btn = e.currentTarget;
            if (btn == this.btnRestart) {
                _super.prototype.onClick.call(this, e);
            }
            else if (btn == this.btnRank) {
                if (this.rankPanel) {
                    moon.GameData.stage.addChild(this.rankPanel);
                }
            }
        };
        return BasicGameOver;
    }(BasicGameStart));
    moon.BasicGameOver = BasicGameOver;
    __reflect(BasicGameOver.prototype, "moon.BasicGameOver");
    /**游戏设置面板*/
    var BasicGameSet = (function (_super) {
        __extends(BasicGameSet, _super);
        function BasicGameSet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        BasicGameSet.prototype.render = function () {
            _super.prototype.render.call(this);
            this.initView();
        };
        BasicGameSet.prototype.initView = function () {
            var containerBg = this.createBackground(0, 0.5);
            this.addChild(containerBg);
            var setbg = new moon.MoonDisplayObject;
            var bgWidth = this.stageWidth >> 1;
            var colorBg = 0XFF9900;
            setbg.type = moon.Const.SHAPE_RECT_ROUND;
            setbg.data = { w: bgWidth * 1.1, h: bgWidth, ew: 100, eh: 100, c: colorBg };
            setbg.setBackground(0XFFFFFF, 5);
            setbg.x = (containerBg.width - bgWidth) >> 1;
            setbg.y = (containerBg.height - bgWidth) >> 1;
            this.addChild(setbg);
            var label1 = new moon.Label("背景音乐", 0XFFFFFF);
            var label2 = new moon.Label("游戏音效", 0XFFFFFF);
            label1.textField.size = 40;
            label2.textField.size = 40;
            label1.x = label2.x = 50;
            label1.y = 50;
            label2.y = 150;
            setbg.addChild(label1);
            setbg.addChild(label2);
            var btn = this.getToggleSwitch();
            btn.x = label1.x + label1.width + 10;
            btn.y = label1.y - 5;
            setbg.addChild(btn);
            this.btnSoundBg = btn;
            var btn = this.getToggleSwitch();
            btn.x = label2.x + label2.width + 10;
            btn.y = label2.y - 5;
            setbg.addChild(btn);
            this.btnSoundEffect = btn;
            var button = new MButton();
            button.label = "关  闭";
            button.x = (setbg.width - button.width) >> 1;
            button.y = 240;
            button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            setbg.addChild(button);
            this.btnClose = button;
        };
        BasicGameSet.prototype.getToggleSwitch = function () {
            var normal = moon.Skin.switchOn;
            var down = moon.Skin.switchOn;
            var normal2 = moon.MoonUI.getSwitch(moon.Color.bule, moon.Color.white);
            var down2 = moon.MoonUI.getSwitch(moon.Color.red, moon.Color.white);
            var btn = new moon.MoreSkinButton([normal, down, normal2, down2]);
            btn.toggleSwitch = true;
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            return btn;
        };
        BasicGameSet.prototype.onClick = function (e) {
            var btn = e.currentTarget;
            var value;
            if (btn == this.btnSoundBg) {
                value = this.btnSoundBg.currentPage;
                alertAuto("背景音乐" + (value == 1 ? "开" : "关"), 1);
                BasicGameStorage.localWrite(BasicGameSet.SOUND_BG, value.toString());
                this.dispEvent(moon.MoonEvent.CHANGE, this.btnSoundBg.currentPage, "soundBg");
            }
            else if (btn == this.btnSoundEffect) {
                value = this.btnSoundEffect.currentPage;
                alertAuto("游戏音效" + (value == 1 ? "开" : "关"), 1);
                BasicGameStorage.localWrite(BasicGameSet.SOUND_EFFECT, value.toString());
                this.dispEvent(moon.MoonEvent.CHANGE, this.btnSoundEffect.currentPage, "soundEffect");
            }
            else if (btn == this.btnClose) {
                this.removeFromParent();
                this.dispEvent(moon.MoonEvent.PLAY);
            }
        };
        BasicGameSet.prototype.setValue = function () {
            var value = BasicGameStorage.localRead(BasicGameSet.SOUND_BG) || "1";
            this.btnSoundBg.updatePage(parseInt(value));
            var value = BasicGameStorage.localRead(BasicGameSet.SOUND_EFFECT) || "1";
            this.btnSoundEffect.updatePage(parseInt(value));
        };
        BasicGameSet.SOUND_BG = "sound bg";
        BasicGameSet.SOUND_EFFECT = "sound effect";
        return BasicGameSet;
    }(moon.BasicView));
    moon.BasicGameSet = BasicGameSet;
    __reflect(BasicGameSet.prototype, "moon.BasicGameSet");
    /**游戏积分排行板*/
    var BasicGameRank = (function (_super) {
        __extends(BasicGameRank, _super);
        function BasicGameRank() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.items = [];
            _this.max = 50;
            return _this;
        }
        BasicGameRank.prototype.render = function () {
            _super.prototype.render.call(this);
            this.initView();
        };
        BasicGameRank.prototype.initView = function () {
            this.createBackground(0, 0.5);
            var rankBg = moon.MoonUI.getRect(this.stageWidth - 100, this.stageHeight - 200, 0);
            rankBg.alpha = 0.8;
            this.addChild(rankBg);
            Layout.getIns().setCenterXByPanent(rankBg);
            Layout.getIns().setCenterYByPanent(rankBg);
            var rect = new Rectangle(rankBg.x, rankBg.y, rankBg.width, rankBg.height);
            var dis = 60;
            var line = new Sprite;
            line.graphics.lineStyle(2, 0XFFFFFF);
            line.graphics.moveTo(rect.x, rect.y + dis);
            line.graphics.lineTo(rect.x, rect.y);
            line.graphics.lineTo(rect.right, rect.y);
            line.graphics.lineTo(rect.right, rect.bottom);
            line.graphics.lineTo(rect.x, rect.bottom);
            line.graphics.lineTo(rect.x, rect.y + dis);
            line.graphics.lineTo(rect.right, rect.y + dis);
            this.addChild(line);
            var xnum = 30;
            var btnSkin = moon.MoonUI.getCircle(xnum, 0xffffff);
            var skinX = moon.MoonUI.getX(xnum >> 1, xnum >> 1, 0x00ff00, 4);
            skinX.anchorOffsetX = skinX.anchorOffsetY = xnum >> 2;
            btnSkin.addChild(skinX);
            var btn = new MButton(btnSkin, btnSkin);
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            this.addChild(btn);
            btn.x = rankBg.x + rankBg.width;
            btn.y = rankBg.y;
            var txt = this.createText(0, 0, "分数排行榜");
            Layout.getIns().setCenterXByPanent(txt);
            txt.y = rankBg.y + (dis - txt.height) / 2;
            this.addChild(txt);
            var txt = this.createText(rankBg.x, rankBg.y - dis / 2);
            this.addChild(txt);
            this.txtRank = txt;
            this.txtRank.text = "你的排名:";
            this.conatiner = new Sprite;
            this.addChild(this.conatiner);
            var itemw = rankBg.width - 2;
            for (var i = 0; i < this.max; i++) {
                var item = new RankItem(itemw, i);
                this.conatiner.addChild(item);
                this.items.push(item);
            }
            moon.SimpleLayout.displayRank(this.items, 1);
            var scrollBar = new moon.ScrollBar();
            scrollBar.target = this.conatiner;
            scrollBar.setSize(rect.width, rect.height - dis - 2);
            scrollBar.layout(moon.Const.VERTICAL);
            this.addChild(scrollBar);
            scrollBar.x = rect.x + 1;
            scrollBar.y = rect.y + dis + 2;
        };
        BasicGameRank.prototype.onClick = function (e) {
            this.removeFromParent();
        };
        BasicGameRank.prototype.update = function (data) {
            var len = this.max;
            var myRank = -1;
            for (var i = 0; i < len; i++) {
                if (i <= this.max) {
                    var score = 100;
                    var item = this.items[i];
                    item.txtScore.text = "" + score;
                    if (i < len - 1) {
                        var next = 90;
                        if (moon.GameData.score > next && moon.GameData.score <= score) {
                            myRank = i;
                        }
                    }
                }
            }
            if (myRank > 0)
                this.txtRank.text = "你的排名:" + myRank;
            else
                this.txtRank.text = "未上榜";
        };
        return BasicGameRank;
    }(moon.BasicView));
    moon.BasicGameRank = BasicGameRank;
    __reflect(BasicGameRank.prototype, "moon.BasicGameRank");
    var RankItem = (function (_super) {
        __extends(RankItem, _super);
        function RankItem(w, rank) {
            var _this = _super.call(this) || this;
            _this.colors = [0, 0XDD823B, 0XD2A85E, 0XDFD164];
            _this.w = w;
            _this.rank = rank + 1;
            _this.initView();
            return _this;
        }
        RankItem.prototype.initView = function () {
            var bg = this.createRect(this.w, 80, 0);
            bg.alpha = this.rank % 2 == 0 ? 0.6 : 0.1;
            this.addChild(bg);
            this.txtRank = this.createText(150, 0);
            this.txtScore = this.createText(350, 0);
            if (this.rank <= 3) {
                this.txtRank.textColor = this.txtScore.textColor = this.colors[this.rank];
            }
            this.txtRank.text = String(this.rank);
            //this.txtScore.text=String(10000-this.rank);
            this.txtScore.text = String(0);
            Layout.getIns().setCenterYByPanent(this.txtRank);
            Layout.getIns().setCenterYByPanent(this.txtScore);
        };
        return RankItem;
    }(moon.BasicView));
    moon.RankItem = RankItem;
    __reflect(RankItem.prototype, "moon.RankItem");
    var SetButton = (function (_super) {
        __extends(SetButton, _super);
        function SetButton() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        SetButton.prototype.render = function () {
            _super.prototype.render.call(this);
            var skin1 = this.getSkin();
            var skin2 = this.getSkin(0XFF5500);
            //skin.filters=[new egret.GlowFilter(0)];
            this.statusNormal = skin1;
            this.statusDown = skin2;
            this.updateSkin(this.statusNormal);
        };
        SetButton.prototype.getSkin = function (bgc) {
            if (bgc === void 0) { bgc = 0XFF9900; }
            var colorBg = bgc;
            var colorIcon = 0X6A4000;
            var container = new Sprite;
            var bgWidth = 90;
            var bg = new moon.MoonDisplayObject;
            bg.type = moon.Const.SHAPE_RECT_ROUND;
            bg.data = { w: bgWidth, h: bgWidth, ew: 30, eh: 30, c: colorBg };
            bg.anchorOffsetX = bg.anchorOffsetY = bgWidth >> 1;
            container.addChild(bg);
            container.addChild(moon.MoonUI.getCircle(30, colorIcon));
            var len = 8;
            var rotation = 360 / len;
            for (var i = 0; i < len; i++) {
                var line = moon.MoonUI.getRect(15, 80, colorIcon);
                line.anchorOffsetX = line.width >> 1;
                line.anchorOffsetY = line.height >> 1;
                line.rotation = rotation * i;
                container.addChild(line);
            }
            container.addChild(moon.MoonUI.getCircle(20, colorBg));
            container.addChild(moon.MoonUI.getCircle(6, colorIcon));
            container.anchorOffsetX = container.anchorOffsetY = -(bgWidth / 2 + 4);
            return container;
        };
        return SetButton;
    }(MButton));
    moon.SetButton = SetButton;
    __reflect(SetButton.prototype, "moon.SetButton");
    /**游戏数据存储*/
    var BasicGameStorage = (function () {
        function BasicGameStorage() {
        }
        /**只能内部访问,在外部修改gameId */
        BasicGameStorage.getGameIdKey = function (key) { return moon.GameData.gameId + key; };
        /**本地 数据写入*/
        BasicGameStorage.localWrite = function (key, value) {
            egret.localStorage.setItem(this.getGameIdKey(key), value);
        };
        /**本地 数据读取*/
        BasicGameStorage.localRead = function (key) {
            return egret.localStorage.getItem(this.getGameIdKey(key));
        };
        /**本地 数据删除*/
        BasicGameStorage.localRemove = function (key) {
            egret.localStorage.removeItem(this.getGameIdKey(key));
        };
        /**本地 数据清空*/
        BasicGameStorage.localClear = function () {
            egret.localStorage.clear();
        };
        /**服务器 数据写入*/
        BasicGameStorage.serverWrite = function () { };
        /**服务器 数据读取*/
        BasicGameStorage.serverRead = function () { return ""; };
        /**服务器 数据删除*/
        BasicGameStorage.serverRemove = function () { };
        return BasicGameStorage;
    }());
    moon.BasicGameStorage = BasicGameStorage;
    __reflect(BasicGameStorage.prototype, "moon.BasicGameStorage");
    /**初始化游戏*/
    var GameMoon = (function () {
        function GameMoon() {
        }
        GameMoon.init = function (stage) {
            //移动端与PC端使用不同模式
            egret.Capabilities.isMobile ? stage.scaleMode = egret.StageScaleMode.FIXED_WIDTH : stage.scaleMode = egret.StageScaleMode.SHOW_ALL;
            //保存好舞台数据 请使用 render()方法中的 this.stageWidth;
            //GameData.stageWidth=stage.stageWidth;
            //GameData.stageHeight=stage.stageHeight;
            moon.GameData.stage = stage;
            //初始化部分功能
            moon.TipsManager.getIns().init(stage);
            moon.LogManager.getIns().init(stage);
            moon.AlertManager.getIns().init(stage);
        };
        return GameMoon;
    }());
    moon.GameMoon = GameMoon;
    __reflect(GameMoon.prototype, "moon.GameMoon");
    /**游戏间的工具类*/
    var GameUtils = (function () {
        function GameUtils() {
        }
        /**把数字转换成时间格式,showNum为3时00:00:00,为2时00:00,为1时00*/
        GameUtils.getTimeFormatByNum = function (num, type, showNum) {
            if (type === void 0) { type = ":"; }
            if (showNum === void 0) { showNum = 3; }
            var s;
            var hour;
            var minute;
            var second;
            if (showNum == 1) {
                second = this.numberFormat(num);
                return second;
            }
            else if (showNum == 2) {
                minute = this.numberFormat((num / 60));
                second = this.numberFormat(num % 60);
                return minute + type + second;
            }
            else {
                hour = this.numberFormat(num / 60 / 60 >> 0);
                minute = this.numberFormat((num / 60) % 60);
                second = this.numberFormat(num % 60);
                return hour + type + minute + type + second;
            }
        };
        /**数字格式，把小于10的数在前面加个0*/
        GameUtils.numberFormat = function (num) {
            num = Math.floor(num);
            if (num >= 10)
                return "" + num;
            else
                return "0" + num;
        };
        /***两点间的距离 */
        GameUtils.twoDistance = function (a, b) {
            var x = a.x - b.x;
            var y = a.y - b.y;
            return Math.sqrt(x * x + y * y);
        };
        return GameUtils;
    }());
    moon.GameUtils = GameUtils;
    __reflect(GameUtils.prototype, "moon.GameUtils");
})(moon || (moon = {}));
var CONST_SCORE_HIGHEST = "playBall score highest"; //最高分数
var GamePanel = { rank: null, over: null, game: null };
var GameMain = (function (_super) {
    __extends(GameMain, _super);
    function GameMain() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    GameMain.prototype.initView = function () {
        //this.createBgGradientFill();
        //面板－主要逻辑处理
        this.panelGame = new GameControl;
        this.panelGame.addEvent(MoonEvent.OVER, this.onOver, this);
        this.addChild(this.panelGame);
        GamePanel.game = this.panelGame;
        //面板－设置
        this.panelSet = new GameSet;
        this.panelSet.addEvent(MoonEvent.PLAY, this.onSetHandler, this);
        this.panelSet.addEvent(MoonEvent.CHANGE, this.onSetHandler, this);
        //面板－开始
        this.panelStart = new GameStart;
        this.panelStart.addEvent(moon.MoonEvent.START, this.start, this);
        this.addChild(this.panelStart);
        //面板－结束
        this.panelOver = new GameOver;
        this.panelOver.addEvent(moon.MoonEvent.START, this.start, this);
        //this.addChild(this.panelOver);
        //按钮－设置
        this.setBtn = new moon.SetButton;
        this.setBtn.x = 100;
        this.setBtn.y = 100;
        this.setBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.openSetPanel, this);
        //this.addChild(this.setBtn);
        //读取历史最高分
        GameData.scoreHighest = Number(moon.BasicGameStorage.localRead(CONST_SCORE_HIGHEST));
    };
    return GameMain;
}(moon.BasicGameMain));
__reflect(GameMain.prototype, "GameMain");
/**开始界面*/
var GameStart = (function (_super) {
    __extends(GameStart, _super);
    function GameStart() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    GameStart.prototype.initView = function () {
        this.createImageBg("startPanel_png");
        var btn = new MButton(new MImage("btnStart_png"), new MImage("btnStart_png"));
        var paihang = new MButton(new MImage("ranking_png"), new MImage("ranking_png"));
        paihang.x = 20;
        paihang.y = 20;
        this.addChild(paihang);
        this.addChild(btn);
        paihang.addEventListener(egret.TouchEvent.TOUCH_TAP, this.dianji, this); //排行榜点击处
        btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
        btn.x = (this.stageWidth - btn.width) >> 1;
        btn.y = 650;
    };
    return GameStart;
}(moon.BasicGameStart));
__reflect(GameStart.prototype, "GameStart");
/**游戏结束 */
var GameOver = (function (_super) {
    __extends(GameOver, _super);
    function GameOver() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.layout = Layout.getIns();
        return _this;
    }
    GameOver.prototype.initView = function () {
        // /**新手指导 */
        // GameControl.GameControlSole.empty1();//清空场景里存在的金币
        this.gameRank = new GameRank();
        GamePanel.rank = this.gameRank;
        GamePanel.over = this;
        this.layout.setStageWH(this.stageWidth, this.stageHeight);
        this.createImageBg("overPanel_png");
        this.btnRestart = this.createMButton("btnRestart_png", 264, 600); //重来
        this.btnScore = this.createMButton("btnScore_png", 425, 600); //分享
        this.btnRank = this.createMButton("btnRank_png", 107, 600); //返回 排行榜
        this.txtScore = this.createText(375, 419);
        this.txtScoreMax = this.createText(375, 497);
        this.txtScore.size = this.txtScoreMax.size = 32;
        //this.txtScore.text=this.txtScoreMax.text="99999";
        this.txtScore.textColor = 0xe8c318;
        this.txtScoreMax.textColor = 0xe8c318;
    };
    GameOver.prototype.createMButton = function (name, x, y) {
        // GameControl.GameControlSole.empty1();//清空所有刚体
        var btn = this.createSkinBtn(name, name);
        btn.x = x;
        btn.y = y;
        return btn;
    };
    GameOver.prototype.createSkinBtn = function (value1, value2) {
        var skin = new Scale9Image(value1);
        var skin2 = new Scale9Image(value2);
        skin2.alpha = 0.5;
        var btn = new MButton(skin, skin2);
        btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
        this.addChild(btn);
        return btn;
    };
    GameOver.prototype.onClick = function (e) {
        if (e.currentTarget == this.btnRestart) {
            this.dispEvent(MoonEvent.START);
            Tween.get(this).to({ alpha: 0 }, 300).call(this.backCall, this);
        }
        else if (e.currentTarget == this.btnScore) {
            //platform.submitScore(GameData.score, this.callback, this);
            platform.activeShare();
        }
        else if (e.currentTarget == this.btnRank) {
            Main.Mainsole.createGameScene();
            Tween.get(this).to({ alpha: 0 }, 300).call(this.backCall, this);
            SoundControl.getIns().stop(MUSIC_BG + "-bg");
        }
        SoundControl.getIns().play(MUSIC_CLICK_BTN);
    };
    /**提交分数返回函数 */
    GameOver.prototype.callback = function (obj) {
        console.log("代码:" + obj.code + ",消息:" + obj.message + ",数据:" + obj.data);
        if (obj.code == 10000) {
            console.log("上传成功");
            alertAuto("分数提交成功");
        }
        else {
            console.log("上传失败");
        }
    };
    GameOver.prototype.update = function (data) {
        GameData.score = data["score"];
        if (GameData.score > GameData.scoreHighest) {
            GameData.scoreHighest = GameData.score;
            moon.BasicGameStorage.localWrite(CONST_SCORE_HIGHEST, GameData.scoreHighest.toString());
        }
        this.txtScore.text = String(GameData.score);
        this.txtScoreMax.text = String(GameData.scoreHighest);
    };
    return GameOver;
}(moon.BasicGameOver));
__reflect(GameOver.prototype, "GameOver");
/**分数排行*/
var GameRank = (function (_super) {
    __extends(GameRank, _super);
    function GameRank() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isdisplay = false;
        return _this;
    }
    GameRank.prototype.setGameHandle = function (game) {
        this.gameHandle = game;
    };
    GameRank.prototype.updateScore = function () {
        platform.getRank(this.update, this);
        //public paihangBtnClick() {
    };
    /**查看排行榜返回函数 */
    GameRank.prototype.update = function (obj) {
        console.log("代码:" + obj.code + ",消息:" + obj.message + ",数据:" + obj.data);
        var _this = GamePanel.rank;
        if (obj.code == 10000) {
            console.log("获取成功");
            var data = obj.data;
            var len = data.length;
            var myRank = -1;
            for (var i = 0; i < len; i++) {
                //this.txtRank.text+=("积分:" + data[i].score + ",排名:" + data[i].rank+"\n");
                var score = data[i].score;
                console.log(i, score, _this.max);
                if (i < _this.max) {
                    var item = _this.items[i];
                    item.txtScore.text = score;
                    console.log("item", item.txtScore.text, score);
                }
                if (i < len - 1) {
                    var next = Number(data[i + 1].score);
                    score = Number(score);
                    console.log(GameData.score, next, score);
                    if (GameData.score == score) {
                        myRank = i + 1;
                    }
                    else if (GameData.score > next && GameData.score <= score) {
                        myRank = i + 2;
                    }
                    else if (GameData.score >= data[0].score) {
                        myRank = 1;
                    }
                    else if (GameData.score <= data[len - 1].score) {
                        myRank = len;
                    }
                }
            }
            if (_this.txtRank) {
                if (myRank > 0)
                    _this.txtRank.text = "你本次得" + GameData.score + "分，排在第" + myRank + "名。";
                else
                    _this.txtRank.text = "未上榜";
            }
        }
        else {
            console.log("获取失败");
        }
    };
    return GameRank;
}(moon.BasicGameRank));
__reflect(GameRank.prototype, "GameRank");
/**分数设置*/
var GameSet = (function (_super) {
    __extends(GameSet, _super);
    function GameSet() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return GameSet;
}(moon.BasicGameSet));
__reflect(GameSet.prototype, "GameSet");
var py2Obj;
(function (py2Obj) {
    var MathUtils = (function () {
        function MathUtils() {
        }
        MathUtils.getCrossPointBetweenCircleAndLine = function (cx, cy, r, stx, sty, edx, edy) {
            // 求直线
            var k = (edy - sty) / (edx - stx);
            var b = edy - k * edx;
            //列方程
            var x1, y1, x2, y2;
            var c = cx * cx + (b - cy) * (b - cy) - r * r;
            var a = (1 + k * k);
            var b1 = (2 * cx - 2 * k * (b - cy));
            var tmp = Math.sqrt(b1 * b1 - 4 * a * c);
            x1 = (b1 + tmp) / (2 * a);
            y1 = k * x1 + b;
            x2 = (b1 - tmp) / (2 * a);
            y2 = k * x2 + b;
            //判断求出的点是否在圆上
            var res = (x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy);
            var p = { x: 0, y: 0 };
            if (res == r * r) {
                p.x = x1;
                p.y = y1;
            }
            else {
                p.x = x2;
                p.y = y2;
            }
            return p;
        };
        MathUtils.getFootfallPoint = function (stx, sty, edx, edy, x, y) {
            var k = (edy - sty) / (edx - stx);
            var b = edy - k * edx;
            var m = x + k * y;
            var pt = { x: 0, y: 0 };
            pt.x = (m - k * b) / (k * k + 1);
            pt.y = (k * pt.x) + b;
            return pt;
        };
        MathUtils.getDistanceBetweenPointAndLine = function (x1, y1, x2, y2, x, y, body) {
            // console.log("&&&&&&&&&&&&&&&" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + x + "," + y);
            var pt = MathUtils.getFootfallPoint(x1, y1, x2, y2, x, y);
            /*  var shape = new egret.Shape();
               shape.graphics.lineStyle(2, 0xff0000);
             shape.graphics.drawCircle(pt.x, pt.y, 10);
               shape.graphics.endFill();
               body.addChild(shape);
               let k= (y1-y2)/(x1-x2);
               let b = y1 -k*y1;
               /// > 0 = ax +b -y;
              */
            return Math.sqrt((x - pt.x) * (x - pt.x) + (y - pt.y) * (y - pt.y));
        };
        /// <summary>
        /// 线段与圆的交点
        /// </summary>
        /// <param name="ptStart">线段起点</param>
        /// <param name="ptEnd">线段终点</param>
        /// <param name="ptCenter">圆心坐标</param>
        /// <param name="Radius2">圆半径平方</param>
        /// <param name="ptInter1">交点1(若不存在返回65536)</param>
        /// <param name="ptInter2">交点2(若不存在返回65536)</param>
        MathUtils.LineInterCircle = function (ptStart, ptEnd, ptCenter, Radius, ptInter1, ptInter2) {
            ptInter1.x = ptInter2.x = 65536;
            ptInter2.y = ptInter2.y = 65536;
            var fDis = Math.sqrt((ptEnd.x - ptStart.x) * (ptEnd.x - ptStart.x) + (ptEnd.y - ptStart.y) * (ptEnd.y - ptStart.y));
            var d = { x: 0, y: 0 };
            d.x = (ptEnd.x - ptStart.x) / fDis;
            d.y = (ptEnd.y - ptStart.y) / fDis;
            var E = { x: 0, y: 0 };
            E.x = ptCenter.x - ptStart.x;
            E.y = ptCenter.y - ptStart.y;
            var a = E.x * d.x + E.y * d.y;
            var a2 = a * a;
            var e2 = E.x * E.x + E.y * E.y;
            var r2 = Radius * Radius;
            if ((r2 - e2 + a2) < 0) {
                return false;
            }
            else {
                var f = Math.sqrt(r2 - e2 + a2);
                var t = a - f;
                ptInter1.x = ptStart.x + t * d.x;
                ptInter1.y = ptStart.y + t * d.y;
                t = a + f;
                ptInter2.x = ptStart.x + t * d.x;
                ptInter2.y = ptStart.y + t * d.y;
                return true;
            }
        };
        MathUtils.EPS = 1e-9; //误差，小于这个就当作0
        return MathUtils;
    }());
    py2Obj.MathUtils = MathUtils;
    __reflect(MathUtils.prototype, "py2Obj.MathUtils");
})(py2Obj || (py2Obj = {}));
/**
     * @author vinson
     * 创建时间：2017-12-18 上午9:36:42
     * P2物理世界的模拟类
     */
var P2World = (function (_super) {
    __extends(P2World, _super);
    function P2World(x, y) {
        if (x === void 0) { x = 0; }
        if (y === void 0) { y = 0; }
        var _this = _super.call(this) || this;
        _this.colors = [10];
        _this.removeBodys = []; //需要删除的刚体
        _this.world = new p2.World({ gravity: [x, y] });
        _this.colors[p2.Body.DYNAMIC] = 0XFF0000;
        _this.colors[p2.Body.KINEMATIC] = 0X00FF00;
        _this.colors[p2.Body.STATIC] = 0X0000FF;
        _this.addEventListener(egret.Event.ENTER_FRAME, _this.updateWorld, _this);
        _this.txtWarn = new egret.TextField;
        return _this;
    }
    Object.defineProperty(P2World.prototype, "p2World", {
        get: function () {
            return this.world;
        },
        enumerable: true,
        configurable: true
    });
    P2World.prototype.getBody = function (mass, type) {
        if (mass === void 0) { mass = 0; }
        if (type === void 0) { type = p2.Body.DYNAMIC; }
        var body = new p2.Body({ mass: mass });
        body.type = type;
        body.userData = {};
        return body;
    };
    /**创建四面墙刚体*/
    P2World.prototype.createWall = function (rect) {
        var bodys = [];
        bodys.push(this.createPlane(0, 0, 0)); //上
        bodys.push(this.createPlane(-Math.PI / 2, 0, 0)); //左
        bodys.push(this.createPlane(Math.PI, 0, rect.height)); //下
        bodys.push(this.createPlane(Math.PI / 2, rect.width, 0)); //右
        return bodys;
    };
    /**创建平面刚体*/
    P2World.prototype.createPlane = function (angle, x, y) {
        if (angle === void 0) { angle = Math.PI; }
        var shape = new p2.Plane();
        var body = this.getBody(0, p2.Body.STATIC);
        body.addShape(shape);
        body.angle = angle;
        body.position[0] = x;
        body.position[1] = y;
        this.world.addBody(body);
        return body;
    };
    /**创建圆形刚体与圆形形状 */
    P2World.prototype.createCircleBodyShape = function (radius, type) {
        if (type === void 0) { type = p2.Body.DYNAMIC; }
        var body = this.getBody(10, type);
        var shape = new p2.Circle({ radius: radius });
        body.addShape(shape);
        this.world.addBody(body);
        return body;
    };
    /***
     * 创建方形刚体与形状
     * angle=rotation*Math.PI/180
     */
    P2World.prototype.createBoxBodyShape = function (width, height, type, angle) {
        if (type === void 0) { type = p2.Body.DYNAMIC; }
        if (angle === void 0) { angle = 0; }
        var body = this.getBody(10, type);
        var shape = new p2.Box({ width: width, height: height });
        body.addShape(shape);
        body.angle = angle;
        this.world.addBody(body);
        return body;
    };
    /**创建多边形刚体与形状(值得注意的是锚点要在中间，这样就不能从[0,0]开始) */
    P2World.prototype.createConvexBodyShape = function (points, type) {
        if (type === void 0) { type = p2.Body.DYNAMIC; }
        var body = this.getBody(10, type);
        body.fromPolygon(points, { optimalDecomp: false });
        this.world.addBody(body);
        return body;
    };
    /**创建正多边形,side边数，radius为半径*/
    P2World.prototype.createPolygon = function (side, radius, type) {
        if (side === void 0) { side = 3; }
        if (radius === void 0) { radius = 30; }
        if (type === void 0) { type = p2.Body.DYNAMIC; }
        var body = this.getBody(10, type);
        var points = [];
        for (var i = 0; i < side; i++) {
            var x = Math.cos((i * (360 / side) * Math.PI / 180)) * radius;
            var y = Math.sin((i * (360 / side) * Math.PI / 180)) * radius;
            points.push([x, y]);
        }
        return this.createConvexBodyShape(points, type);
    };
    /**创建圆与方的组合体 */
    P2World.prototype.createBoxCircleBodyShape = function (width, height, type) {
        if (type === void 0) { type = p2.Body.DYNAMIC; }
        var body = this.getBody(10, type);
        body.fixedRotation = true;
        width /= 2;
        height /= 1.5;
        var shape = new p2.Box({ width: width, height: height });
        var shape2 = new p2.Circle({ radius: width / 2 });
        body.addShape(shape);
        body.addShape(shape2);
        shape.position[1] = -height;
        shape2.position[1] = -width / 2;
        this.world.addBody(body);
        return body;
    };
    /**创建刚体皮肤，如果外面设置了刚体皮肤，就不需要调用这个方法了*/
    P2World.prototype.drawSkin = function (body) {
        var skin = new egret.Sprite();
        var color = this.colors[body.type];
        skin.graphics.lineStyle(1, color, 1);
        skin.graphics.beginFill(color, 0.5);
        for (var i = 0; i < body.shapes.length; i++) {
            var shape = body.shapes[i];
            var pos = new egret.Point(shape.position[0], shape.position[1]);
            if (shape instanceof p2.Box) {
                var width = shape.width, height = shape.height;
                var w2 = width / 2, h2 = height / 2;
                skin.graphics.moveTo(pos.x, pos.y);
                skin.graphics.lineTo(pos.x - w2, pos.y - h2);
                skin.graphics.drawRect(pos.x - w2, pos.y - h2, width, height);
                skin.graphics.endFill();
            }
            else if (shape instanceof p2.Convex) {
                var vertices = shape.vertices;
                var verLen = vertices.length;
                var vert = vertices[0];
                skin.graphics.moveTo(0, 0);
                skin.graphics.lineTo(vert[0], vert[1]);
                for (var j = 0; j < verLen; j++) {
                    vert = vertices[j];
                    if (j == 0)
                        skin.graphics.moveTo(vert[0], vert[1]);
                    else
                        skin.graphics.lineTo(vert[0], vert[1]);
                }
                var vert = vertices[0];
                skin.graphics.lineTo(vert[0], vert[1]);
                skin.graphics.endFill();
            }
            else if (shape instanceof p2.Circle) {
                var radius = shape.radius;
                skin.graphics.moveTo(pos.x, pos.y);
                skin.graphics.lineTo(pos.x, radius + pos.y);
                skin.graphics.drawCircle(pos.x, pos.y, radius);
                skin.graphics.endFill();
            }
        }
        skin.x = body.position[0];
        skin.y = body.position[1];
        body.userData.skin = skin;
        this.addChild(skin);
        return skin;
    };
    /**更新世界*/
    P2World.prototype.updateWorld = function (e) {
        var timeStep = 1 / 60;
        var removeBodys = this.removeBodys;
        this.world.step(timeStep);
        var bodys = this.world.bodies;
        var l = bodys.length;
        for (var i = 0; i < l; i++) {
            var body = bodys[i];
            if (body.userData && body.userData.skin) {
                var skin = body.userData.skin;
                /*var shape = new egret.Shape();
                shape.graphics.lineStyle(2, 0x00ff00);

                shape.graphics.drawCircle( body.position[0], body.position[1],13);
                    
                 this.addChild(shape);*/
                skin.x = body.position[0];
                skin.y = body.position[1];
                skin.rotation = body.angle * 180 / Math.PI;
            }
            else {
                if (!(body.shapes[0] instanceof p2.Plane)) {
                    // this.txtWarn.x=this.txtWarn.y=200
                    // this.addChild(this.txtWarn);
                    // this.txtWarn.text="警告：有刚体没有设置皮肤"
                }
            }
        }
        for (i = 0; i < removeBodys.length; i++) {
            body = removeBodys[i];
            if (body.userData && body.userData.skin) {
                skin = body.userData.skin;
                if (skin.parent != null) {
                    //skin.parent.removeChild(skin);
                }
                body.userData = null;
            }
            this.world.removeBody(body);
        }
        if (this.loopBackFun != null) {
            this.loopBackFun();
        }
    };
    return P2World;
}(egret.DisplayObjectContainer));
__reflect(P2World.prototype, "P2World");
/**
 * 声音控制单例管理类
 * 创建时间2017/12/5
 * @author vinson
 */
var SoundControl = (function (_super) {
    __extends(SoundControl, _super);
    function SoundControl() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.sounds = {};
        _this.channels = {};
        _this.volumeBg = 1;
        _this.volumeEffect = 1;
        _this.isNoVolume = 1;
        return _this;
    }
    SoundControl.getIns = function () {
        if (this.instance == null) {
            this.instance = new SoundControl();
        }
        return this.instance;
    };
    /**
    * 判断是否为背景声音
    * @param data 声音容器
    * @param name 声音名字
    */
    SoundControl.prototype.checkSoundIsBg = function (data, name) {
        return data[name + "-bg"];
    };
    /**
    * 声音必须是预先已经加载好的
    * @param name 声音名字
    * @param isBgSound 是不是背景声音
    */
    SoundControl.prototype.addItem = function (name, isBgSound) {
        if (isBgSound === void 0) { isBgSound = false; }
        var soundName = name;
        if (isBgSound) {
            soundName = name + "-bg";
        }
        if (!this.sounds[soundName]) {
            var sound = RES.getRes(name);
            this.sounds[soundName] = sound;
        }
    };
    /**
     * 声音必须是预先已经加载好的
     * @param name 声音名字
     * @param start 开始播放的地方，默认从头开始播放
     * @param loop 循环播放次数，默认是1次
     */
    SoundControl.prototype.play = function (name, start, loop) {
        if (start === void 0) { start = 0; }
        if (loop === void 0) { loop = 1; }
        var volume = this.volumeEffect;
        if (this.checkSoundIsBg(this.sounds, name)) {
            name = name + "-bg";
            volume = this.volumeBg;
        }
        if (this.sounds[name]) {
            var sound = this.sounds[name];
            this.channels[name] = sound.play(start, loop);
            if (this.isNoVolume == 0) {
                this.channels[name].volume = 0;
            }
            else {
                this.channels[name].volume = volume;
            }
        }
    };
    /**
     * 声音必须是预先已经加载好的
     * @param name 声音名字
     */
    SoundControl.prototype.stop = function (name) {
        if (this.checkSoundIsBg(this.channels, name)) {
            name = name + "-bg";
        }
        if (this.channels[name]) {
            var channel = this.channels[name];
            channel.stop();
        }
    };
    /**
     * 设置某个声音的音量
     *  @param name 声音名字
     *  @param volume 音量0－1
     */
    SoundControl.prototype.setVolume = function (name, volume) {
        if (this.checkSoundIsBg(this.channels, name)) {
            name = name + "-bg";
        }
        if (this.channels[name]) {
            var channel = this.channels[name];
            channel.volume = volume;
        }
    };
    /**
     * 设置所有背景声音音量
     * @param volume 音量0－1
     */
    SoundControl.prototype.setBgVolume = function (volume) {
        for (var name in this.channels) {
            if (name.split("-bg").length == 2) {
                var channel = this.channels[name];
                this.volumeBg = volume;
                if (channel.position != 0) {
                    channel.volume = volume;
                }
            }
        }
    };
    /**
     * 设置所有特效声音音量
     * @param volume 音量0－1
     */
    SoundControl.prototype.setEffectVolume = function (volume) {
        for (var name in this.channels) {
            if (name.split("-bg").length == 1) {
                var channel = this.channels[name];
                this.volumeEffect = volume;
                if (channel.position != 0) {
                    channel.volume = volume;
                }
            }
        }
    };
    /**设置是否静音
    * @param volume 是否静音0为无音1为有音
    */
    SoundControl.prototype.setIsNoVolume = function (volume) {
        this.isNoVolume = volume;
        for (var name in this.channels) {
            var channel = this.channels[name];
            if (channel.position != 0) {
                if (volume == 0) {
                    channel.volume = 0;
                }
                else {
                    if (this.checkSoundIsBg(this.sounds, name)) {
                        channel.volume = this.volumeBg;
                    }
                    else {
                        channel.volume = this.volumeEffect;
                    }
                }
            }
        }
    };
    return SoundControl;
}(egret.HashObject));
__reflect(SoundControl.prototype, "SoundControl");
//////////////////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2014-present, Egret Technology.
//  All rights reserved.
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of the Egret nor the
//       names of its contributors may be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
//  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
//  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
//  IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
//  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
//  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
//  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var LoadingUI = (function (_super) {
    __extends(LoadingUI, _super);
    function LoadingUI() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.addToStage, _this);
        return _this;
    }
    LoadingUI.prototype.addToStage = function () {
        this.removeEventListener(egret.Event.ADDED_TO_STAGE, this.addToStage, this);
        //this.gameLoad = new moon.GameLoad;
        //this.addChild(this.gameLoad);
    };
    LoadingUI.prototype.onProgress = function (current, total) {
        //this.gameLoad.update(current/total);
        //  platform.progress(current/total);
    };
    return LoadingUI;
}(egret.Sprite));
__reflect(LoadingUI.prototype, "LoadingUI", ["RES.PromiseTaskReporter"]);
//子弹基础类(10 开始)
//1.生成子弹图片
//2.更换子弹的刚体
//3.负责子弹的移动，或者给力
//4.负责子弹的停止
var py2Obj;
(function (py2Obj) {
    var basicBullet = (function (_super) {
        __extends(basicBullet, _super);
        function basicBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //保存外部的物理世界
            _this.pointList = [];
            _this.objkind = 100;
            return _this;
        }
        basicBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        basicBullet.prototype.createMyRigidbody = function () {
            //this.bool=true;
            var world = this.m_world;
            var skin = this.createSkin("ball2_png");
            var body = world.createCircleBodyShape(13, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            shape.collisionMask = 6;
            //this.label.x = this.m_body.position[0];
            //this.label.y = this.m_body.position[1];
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        basicBullet.prototype.createMyRigidbody1 = function () {
            var world = this.m_world;
            var skin = this.createSkin("purpleBall_png");
            var body = world.createCircleBodyShape(13, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            shape.collisionMask = 6;
            //this.label.x = this.m_body.position[0];
            //this.label.y = this.m_body.position[1];
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        basicBullet.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            // if (otherBody.objkind == 103) {	
            // 	this.removebullet(this);
            // }
        };
        basicBullet.prototype.removeBasicbullet = function (ba) {
            this.m_world.removeBodys.push(ba.getBody());
            this.m_removeSkins.push(ba.getBody().userData.skin);
        };
        return basicBullet;
    }(py2Obj.basicObj));
    py2Obj.basicBullet = basicBullet;
    __reflect(basicBullet.prototype, "py2Obj.basicBullet");
})(py2Obj || (py2Obj = {}));
var py2Obj;
(function (py2Obj) {
    var BlueBullet = (function (_super) {
        __extends(BlueBullet, _super);
        //public label: egret.TextField = new egret.TextField();
        function BlueBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.isRun = false;
            _this.pointList = [];
            _this.cishu = 0;
            _this.objkind = 301;
            return _this;
        }
        BlueBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        BlueBullet.prototype.send = function (x, y, forcex, forcey) {
            this.m_body.type = 1;
            this.isRun = true;
            this.m_body.velocity = [0, 0];
            this.m_body.damping = 0;
            this.setPostion(x, y);
            this.setForce(forcex, forcey);
            this.a = forcex; //新手引导
            this.b = forcey; //新手引导
            if (this.cishu == 0 && tishi < 9) {
                this.cishu = 1;
                var timer = new egret.Timer(500, 1);
                timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerCom, this);
                timer.start();
            } //新手引导
        };
        BlueBullet.prototype.timerCom = function () {
            this.setForce(this.a * -1, this.b * -1);
            GameControl.GameControlSole.upgradeNumber2 = 2;
            GameControl.GameControlSole.UpgradeTishi();
        }; //新手引导
        BlueBullet.prototype.createMyRigidbody = function () {
            // this.label.text = "0";
            // this.label.height = 100;
            // this.label.width = 200;
            // this.label.size = 28;
            // this.label.textColor = 0xFF0000;
            // this.label.x = this.m_body.position[0];
            // this.label.y = this.m_body.position[1];
            var world = this.m_world;
            var skin = this.createSkin("purpleBall_png");
            var body = world.createCircleBodyShape(13);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            // var skin1: MImage = this.createSkin(this.label.text);
            // var body1: p2.Body = world.createCircleBodyShape(10);
            // body1.userData.skin = skin1;
            // body1.userData.data = this;
            // body1.mass = 0;//质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            // body.gravityScale = 0;
            // var shape1 = body1.shapes[0];
            // shape.collisionGroup = 2;//010与001为0，010与110为1
            // shape1.collisionMask = 6;
            // this.label.x = this.m_body.position[0];
            // this.label.y = this.m_body.position[1];
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        // protected createText(x: number = 0, y: number = 0, s: string = ""): TextField {
        // 	var text: TextField = (new Label).textField;
        // 	text.x = x; text.y = y; text.text = s;
        // 	this.addChild(text);
        // 	return text;
        // }
        BlueBullet.prototype.createFixedBullet = function () {
        };
        BlueBullet.prototype.runEnd = function () {
            var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
            bullet.init();
            bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            this.m_gamePanle.doMaterial(bullet.getBody());
            // bullet.setForce(this.vec.x, this.vec.y);
            // this.setChildIndex(this.gun, this.numChildren - 1);
            this.isRun = false;
            this.recyle1();
            return bullet;
        };
        BlueBullet.prototype.runEnd1 = function () {
            this.m_body.type = 3; //该死的 终于找到你
            this.isRun = true;
        };
        BlueBullet.prototype.recyle1 = function () {
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-100, -100);
            this.isRun = false;
        };
        BlueBullet.prototype.recyle = function () {
            this.isRun = true;
            this.m_body.type = 2;
            this.time = new egret.Timer(50, 1);
            this.time.start(); //开始计时
            this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
        };
        BlueBullet.prototype.jishi = function () {
            this.isRun = true;
            this.m_body.type = 1;
        };
        BlueBullet.prototype.strikeRecyle = function () {
            this.m_body.type = 3;
        };
        /**
         * Body.KINEMATIC = 4;
         * Body.STATIC = 2;
         * Body.DYNAMIC = 1;
         */
        BlueBullet.prototype.getCollision = function (otherBody) {
            if (otherBody.objkind == 100) {
                return;
            }
            if (otherBody.objkind == 500) {
                return;
            }
            if (otherBody.objkind == 600) {
                return;
            }
        };
        return BlueBullet;
    }(py2Obj.basicObj));
    py2Obj.BlueBullet = BlueBullet;
    __reflect(BlueBullet.prototype, "py2Obj.BlueBullet");
})(py2Obj || (py2Obj = {}));
var py2Obj;
(function (py2Obj) {
    var BoomBullet = (function (_super) {
        __extends(BoomBullet, _super);
        function BoomBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.isRun = false;
            _this.pointList = [];
            _this.objkind = 102;
            return _this;
        }
        BoomBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        BoomBullet.prototype.send = function (x, y, forcex, forcey) {
            this.m_body.type = 1;
            this.isRun = true;
            this.m_body.velocity = [0, 0];
            this.m_body.damping = 0;
            this.setPostion(x, y);
            this.setForce(forcex, forcey);
        };
        BoomBullet.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("raind_png"); //redball_png
            var body = world.createCircleBodyShape(13);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            return body;
        };
        BoomBullet.prototype.createFixedBullet = function () {
        };
        /**摁第二次进入的方法 */
        BoomBullet.prototype.runEnd = function () {
            SoundControl.getIns().addItem(MUSIC_BaoZha);
            SoundControl.getIns().play(MUSIC_BaoZha, 0, 1);
            GameControl.GameControlSole.bombBlasts(this.m_body.position[0], this.m_body.position[1]); //进入爆炸消除东西的判断方法里
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-250, -250);
            this.isRun = false;
        };
        // /** 碰撞到金币进入的方法 */
        BoomBullet.prototype.runEnd2 = function () {
            var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
            bullet.init();
            bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            this.m_gamePanle.doMaterial(bullet.getBody());
            // bullet.setForce(this.vec.x, this.vec.y);
            // this.setChildIndex(this.gun, this.numChildren - 1);
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-150, -150);
            this.isRun = false;
            GameControl.GameControlSole.crashGold();
            return bullet;
        };
        BoomBullet.prototype.recyle = function () {
            this.isRun = true;
            this.m_body.type = 2;
            this.time = new egret.Timer(50, 1);
            this.time.start(); //开始计时
            this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
        };
        BoomBullet.prototype.jishi = function () {
            this.isRun = true;
            this.m_body.type = 1;
        };
        BoomBullet.prototype.runEnd1 = function () {
            this.m_body.type = 3;
            this.isRun = true;
        };
        BoomBullet.prototype.strikeRecyle = function () {
            this.m_body.type = 3;
        };
        // public recyle() {
        // }
        BoomBullet.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            //if (otherBody.objkind == 100||otherBody.objkind == 400) {
            // 	var boombullet = new py2Obj.clrcle(this.m_world, this.m_gamePanle, this.m_removeSkins);
            // 	boombullet.init();
            // 	boombullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            // 	this.m_gamePanle.doMaterial(boombullet.getBody());
            // 	var timer:egret.Timer=new egret.Timer(200,1);
            // 	timer.start();
            // 	 timer.addEventListener(egret.TimerEvent.TIMER, ()=>{
            //     boombullet.removebullet(boombullet);
            // }, this);
            // }
            if (otherBody.objkind == 401 || otherBody.objkind == 402 || otherBody.objkind == 404 || otherBody.objkind == 405 || otherBody.objkind == 406) {
                this.recyle();
            }
            if (otherBody.objkind == 200 || otherBody.objkind == 201) {
                this.runEnd();
            }
            if (otherBody.objkind == 108) {
                this.strikeRecyle();
            }
        };
        return BoomBullet;
    }(py2Obj.basicObj));
    py2Obj.BoomBullet = BoomBullet;
    __reflect(BoomBullet.prototype, "py2Obj.BoomBullet");
})(py2Obj || (py2Obj = {}));
var py2Obj;
(function (py2Obj) {
    /**本地地图上所有青蛙 */
    var bulletManager = (function (_super) {
        __extends(bulletManager, _super);
        //玩家加分
        function bulletManager(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            /** 用来存储所有的子弹*/
            _this.m_bullet = [];
            _this.arr = [];
            _this.pointArr = []; //随机位置
            return _this;
        }
        bulletManager.prototype.removePorp = function (ba) {
            var index = this.m_bullet.indexOf(ba);
            if (index > -1) {
                this.m_bullet.splice(index, 1);
            }
            else {
                return;
            }
            this.m_removeSkins.push(ba.getBody().userData.skin);
            this.m_world.removeBodys.push(ba.getBody());
            this.createProp(1);
        };
        bulletManager.prototype.removePorp1 = function (ba) {
            var index = this.m_bullet.indexOf(ba);
            if (index > -1) {
                this.m_bullet.splice(index, 1);
            }
            else {
                return;
            }
            this.m_removeSkins.push(ba.getBody().userData.skin);
            this.m_world.removeBodys.push(ba.getBody());
            this.createProp(2);
        };
        //根据玩家的等级来创建一个或者多个道具
        bulletManager.prototype.createProp = function (level) {
        };
        bulletManager.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        bulletManager.prototype.createMyRigidbody = function () {
            return null;
        };
        return bulletManager;
    }(py2Obj.basicObj));
    py2Obj.bulletManager = bulletManager;
    __reflect(bulletManager.prototype, "py2Obj.bulletManager");
})(py2Obj || (py2Obj = {}));
var py2Obj;
(function (py2Obj) {
    var clrcle = (function (_super) {
        __extends(clrcle, _super);
        //保存外部的物理世界
        function clrcle(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.objkind = 103;
            return _this;
        }
        clrcle.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        clrcle.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("redball2_png");
            var body = world.createCircleBodyShape(30, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            shape.collisionMask = 6;
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        clrcle.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
        };
        clrcle.prototype.removebullet = function (ba) {
            this.m_world.removeBodys.push(ba.getBody());
            this.m_removeSkins.push(ba.getBody().userData.skin);
        };
        return clrcle;
    }(py2Obj.basicObj));
    py2Obj.clrcle = clrcle;
    __reflect(clrcle.prototype, "py2Obj.clrcle");
})(py2Obj || (py2Obj = {}));
//假子弹基础类(紧紧用来演示射击)
//1.生成子弹图片
//2.更换子弹的刚体
//3.负责子弹的移动，或者给力
//4.负责子弹的停止
var py2Obj;
(function (py2Obj) {
    var fakeBullet = (function (_super) {
        __extends(fakeBullet, _super);
        //public label: egret.TextField = new egret.TextField();
        function fakeBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.isRun = false;
            _this.pointList = [];
            _this.cishu = 0;
            _this.objkind = 301;
            return _this;
        }
        fakeBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        fakeBullet.prototype.send = function (x, y, forcex, forcey) {
            this.m_body.type = 1;
            this.isRun = true;
            this.m_body.velocity = [0, 0];
            this.m_body.damping = 0;
            this.setPostion(x, y);
            this.setForce(forcex, forcey);
            this.a = forcex; //新手引导
            this.b = forcey; //新手引导
            if (this.cishu == 0 && tishi < 9) {
                this.cishu = 1;
                var timer = new egret.Timer(500, 1);
                timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerCom, this);
                timer.start();
            } //新手引导
        };
        fakeBullet.prototype.timerCom = function () {
            this.setForce(this.a * -1, this.b * -1);
            GameControl.GameControlSole.upgradeNumber2 = 2;
            GameControl.GameControlSole.UpgradeTishi();
        }; //新手引导
        fakeBullet.prototype.createMyRigidbody = function () {
            // this.label.text = "0";
            // this.label.height = 100;
            // this.label.width = 200;
            // this.label.size = 28;
            // this.label.textColor = 0xFF0000;
            // this.label.x = this.m_body.position[0];
            // this.label.y = this.m_body.position[1];
            var world = this.m_world;
            var skin = this.createSkin("ball_png");
            var body = world.createCircleBodyShape(13);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            // var skin1: MImage = this.createSkin(this.label.text);
            // var body1: p2.Body = world.createCircleBodyShape(10);
            // body1.userData.skin = skin1;
            // body1.userData.data = this;
            // body1.mass = 0;//质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            // body.gravityScale = 0;
            // var shape1 = body1.shapes[0];
            // shape.collisionGroup = 2;//010与001为0，010与110为1
            // shape1.collisionMask = 6;
            // this.label.x = this.m_body.position[0];
            // this.label.y = this.m_body.position[1];
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        // protected createText(x: number = 0, y: number = 0, s: string = ""): TextField {
        // 	var text: TextField = (new Label).textField;
        // 	text.x = x; text.y = y; text.text = s;
        // 	this.addChild(text);
        // 	return text;
        // }
        fakeBullet.prototype.createFixedBullet = function () {
        };
        fakeBullet.prototype.runEnd = function () {
            var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
            bullet.init();
            bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            this.m_gamePanle.doMaterial(bullet.getBody());
            // bullet.setForce(this.vec.x, this.vec.y);
            // this.setChildIndex(this.gun, this.numChildren - 1);
            this.isRun = false;
            this.recyle1();
            return bullet;
        };
        fakeBullet.prototype.runEnd1 = function () {
            this.m_body.type = 3; //该死的 终于找到你
            this.isRun = true;
        };
        fakeBullet.prototype.recyle1 = function () {
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-100, -100);
            this.isRun = false;
        };
        fakeBullet.prototype.recyle = function () {
            this.isRun = true;
            this.m_body.type = 2;
            this.time = new egret.Timer(50, 1);
            this.time.start(); //开始计时
            this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
        };
        fakeBullet.prototype.jishi = function () {
            this.isRun = true;
            this.m_body.type = 1;
        };
        fakeBullet.prototype.strikeRecyle = function () {
            this.m_body.type = 3;
        };
        /**
         * Body.KINEMATIC = 4;
         * Body.STATIC = 2;
         * Body.DYNAMIC = 1;
         */
        fakeBullet.prototype.getCollision = function (otherBody) {
            if (otherBody.objkind == 100) {
                return;
            }
            if (otherBody.objkind == 500) {
                return;
            }
            if (otherBody.objkind == 600) {
                return;
            }
        };
        return fakeBullet;
    }(py2Obj.basicObj));
    py2Obj.fakeBullet = fakeBullet;
    __reflect(fakeBullet.prototype, "py2Obj.fakeBullet");
})(py2Obj || (py2Obj = {}));
//替代假子弹的固定不动的子弹，起反弹作用
var py2Obj;
(function (py2Obj) {
    var fixBullet = (function (_super) {
        __extends(fixBullet, _super);
        function fixBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.isRun = false;
            _this.objkind = 102;
            return _this;
        }
        fixBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        fixBullet.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("ball_png");
            var body = world.createCircleBodyShape(skin.width >> 1);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        fixBullet.prototype.createFixedBullet = function () {
        };
        /**
         * Body.KINEMATIC = 4;
         * Body.STATIC = 2;
         * Body.DYNAMIC = 1;
         */
        fixBullet.prototype.getCollision = function (otherBody) {
            // if(otherBody.objkind==301)
            // {
            // 	 otherBody.getBody().applyImpulse([this.m_body.position[0] * 2, 0], [0, 0]);
            // }
            // 	this.setPostion(this.m_body.position[0], this.m_body.position[1]);
        };
        return fixBullet;
    }(py2Obj.basicObj));
    py2Obj.fixBullet = fixBullet;
    __reflect(fixBullet.prototype, "py2Obj.fixBullet");
})(py2Obj || (py2Obj = {}));
//重力子弹
var py2Obj;
(function (py2Obj) {
    var gravityBullet = (function (_super) {
        __extends(gravityBullet, _super);
        function gravityBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.isRun = false;
            _this.pointList = [];
            _this.objkind = 104;
            return _this;
        }
        gravityBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        gravityBullet.prototype.send = function (x, y, forcex, forcey) {
            this.m_body.type = 1;
            this.isRun = true;
            this.m_body.velocity = [0, 0];
            this.m_body.damping = 0;
            this.setPostion(x, y);
            this.setForce(forcex, forcey);
        };
        gravityBullet.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("zhong_png");
            var body = world.createCircleBodyShape(13);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        gravityBullet.prototype.createFixedBullet = function () {
        };
        gravityBullet.prototype.runEnd2 = function () {
            var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
            bullet.init();
            bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            this.m_gamePanle.doMaterial(bullet.getBody());
            // bullet.setForce(this.vec.x, this.vec.y);
            // this.setChildIndex(this.gun, this.numChildren - 1);
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-100, -100);
            this.isRun = false;
            GameControl.GameControlSole.crashGold();
            return bullet;
        };
        gravityBullet.prototype.runEnd = function (x, y) {
            this.setForce(x, y); //给一个向下的力
            this.m_body.type = 3; //该死的 终于找到你
            this.isRun = null;
        };
        gravityBullet.prototype.runEnd1 = function () {
            this.m_body.type = 3;
            this.isRun = true;
        };
        gravityBullet.prototype.timerFunc = function () {
            console.log(88);
        };
        gravityBullet.prototype.recyle = function () {
            this.isRun = true;
            this.m_body.type = 2;
            this.time = new egret.Timer(50, 1);
            this.time.start(); //开始计时
            this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
        };
        gravityBullet.prototype.recyle1 = function () {
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-100, -100);
            this.isRun = false;
        };
        gravityBullet.prototype.jishi = function () {
            this.isRun = true;
            this.m_body.type = 1;
        };
        gravityBullet.prototype.strikeRecyle = function () {
            this.m_body.type = 3;
        };
        /**
         * Body.KINEMATIC = 4;
         * Body.STATIC = 2;
         * Body.DYNAMIC = 1;
         */
        gravityBullet.prototype.getCollision = function (otherBody) {
            if (otherBody.objkind == 100 || this.m_body.type == 3) {
                return;
            }
            if (otherBody.objkind == 200 || otherBody.objkind == 201) {
                this.recyle1();
            }
            if (otherBody.objkind == 108) {
                this.strikeRecyle();
                var bb = 1;
            }
            if (bb == null) {
                this.recyle();
            }
        };
        return gravityBullet;
    }(py2Obj.basicObj));
    py2Obj.gravityBullet = gravityBullet;
    __reflect(gravityBullet.prototype, "py2Obj.gravityBullet");
})(py2Obj || (py2Obj = {}));
//////////////////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2014-present, Egret Technology.
//  All rights reserved.
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of the Egret nor the
//       names of its contributors may be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
//  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
//  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
//  IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
//  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
//  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
//  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var Main = (function (_super) {
    __extends(Main, _super);
    function Main() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this);
        Main.Mainsole = _this;
        return _this;
    }
    Main.prototype.onAddToStage = function (event) {
        //初始化moon组件
        moon.GameMoon.init(this.stage);
        moon.GameData.version = moon.Const.VER_RELEASE;
        egret.lifecycle.addLifecycleListener(function (context) {
            // custom lifecycle plugin
            context.onUpdate = function () {
            };
        });
        egret.lifecycle.onPause = function () {
            egret.ticker.pause();
        };
        egret.lifecycle.onResume = function () {
            egret.ticker.resume();
        };
        this.runGame().catch(function (e) {
            console.log(e);
        });
    };
    Main.prototype.runGame = function () {
        return __awaiter(this, void 0, void 0, function () {
            var result, userInfo;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.loadResource()];
                    case 1:
                        _a.sent();
                        this.createGameScene();
                        return [4 /*yield*/, RES.getResAsync("description_json")];
                    case 2:
                        result = _a.sent();
                        return [4 /*yield*/, platform.login()];
                    case 3:
                        _a.sent();
                        return [4 /*yield*/, platform.getUserInfo()];
                    case 4:
                        userInfo = _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    Main.prototype.loadResource = function () {
        return __awaiter(this, void 0, void 0, function () {
            var loadingView, e_1;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _a.trys.push([0, 3, , 4]);
                        loadingView = new LoadingUI();
                        this.stage.addChild(loadingView);
                        return [4 /*yield*/, RES.loadConfig("resource/default.res.json", "resource/")];
                    case 1:
                        _a.sent();
                        return [4 /*yield*/, RES.loadGroup("preload", 0, loadingView)];
                    case 2:
                        _a.sent();
                        this.stage.removeChild(loadingView);
                        return [3 /*break*/, 4];
                    case 3:
                        e_1 = _a.sent();
                        console.error(e_1);
                        return [3 /*break*/, 4];
                    case 4: return [2 /*return*/];
                }
            });
        });
    };
    /**
     * 创建游戏场景
     * Create a game scene
     */
    Main.prototype.createGameScene = function () {
        platform.onshareMessage();
        platform.showShareMenu();
        this.addChild(new GameMain); //new GameMain
        //  GameControl.GameControlSole .newtext();
    };
    return Main;
}(egret.DisplayObjectContainer));
__reflect(Main.prototype, "Main");
//触发子弹
var py2Obj;
(function (py2Obj) {
    var strikeBullet = (function (_super) {
        __extends(strikeBullet, _super);
        function strikeBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //private label: TextField;
            _this.isRun = false;
            _this.pointList = [];
            _this.objkind = 105;
            return _this;
        }
        strikeBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        strikeBullet.prototype.send = function (x, y, forcex, forcey) {
            this.m_body.type = 1;
            this.isRun = true;
            this.m_body.velocity = [0, 0];
            this.m_body.damping = 0;
            this.setPostion(x, y);
            this.setForce(forcex, forcey);
        };
        strikeBullet.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("chu_png");
            var body = world.createCircleBodyShape(13);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            return body;
        };
        strikeBullet.prototype.createFixedBullet = function () {
        };
        strikeBullet.prototype.runEnd = function () {
            var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
            bullet.init();
            bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            this.m_gamePanle.doMaterial(bullet.getBody());
            // bullet.setForce(this.vec.x, this.vec.y);
            // this.setChildIndex(this.gun, this.numChildren - 1);
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-100, -100);
            this.isRun = false;
            GameControl.GameControlSole.crashGold();
            return bullet;
        };
        strikeBullet.prototype.runEnd1 = function () {
            var bullet = new py2Obj.strikeFixationBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
            bullet.init();
            bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            this.m_gamePanle.doMaterial(bullet.getBody());
            // bullet.setForce(this.vec.x, this.vec.y);
            // this.setChildIndex(this.gun, this.numChildren - 1);
            this.isRun = false;
            this.recyle1();
            return bullet;
        };
        strikeBullet.prototype.recyle1 = function () {
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-100, -100);
            this.isRun = false;
        };
        strikeBullet.prototype.recyle = function () {
            this.isRun = true;
            this.m_body.type = 2;
            this.time = new egret.Timer(50, 1);
            this.time.start(); //开始计时
            this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
        };
        strikeBullet.prototype.jishi = function () {
            this.isRun = true;
            this.m_body.type = 1;
        };
        /**
         * Body.KINEMATIC = 4;
         * Body.STATIC = 2;
         * Body.DYNAMIC = 1;
         */
        strikeBullet.prototype.getCollision = function (otherBody) {
            if (otherBody.objkind == 100) {
                return;
            }
            this.recyle();
        };
        return strikeBullet;
    }(py2Obj.basicObj));
    py2Obj.strikeBullet = strikeBullet;
    __reflect(strikeBullet.prototype, "py2Obj.strikeBullet");
})(py2Obj || (py2Obj = {}));
// TypeScript file
var py2Obj;
(function (py2Obj) {
    var strikeFixationBullet = (function (_super) {
        __extends(strikeFixationBullet, _super);
        function strikeFixationBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //保存外部的物理世界
            _this.pointList = [];
            _this.label = new egret.TextField();
            _this.objkind = 108;
            return _this;
        }
        strikeFixationBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        strikeFixationBullet.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("chu_png");
            var body = world.createCircleBodyShape(13, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            shape.collisionMask = 6;
            this.label.text = "0";
            this.label.height = 100;
            this.label.width = 200;
            this.label.size = 28;
            this.label.textColor = 0xFF0000;
            // this.label.x = this.m_body.position[0];
            // this.label.y = this.m_body.position[1];
            //this.label.x = this.m_body.position[0];
            //this.label.y = this.m_body.position[1];
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        // protected createText(x: number = 0, y: number = 0, s: string = ""): TextField {
        // 	var text: TextField = (new Label).textField;
        // 	text.x = x; text.y = y; text.text = s;
        // 	this.addChild(text);
        // 	return text;
        // }
        strikeFixationBullet.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            // if (otherBody.objkind == 103) {	
            // 	this.removebullet(this);
            // }
        };
        strikeFixationBullet.prototype.removeBasicbullet = function (ba) {
            this.m_world.removeBodys.push(ba.getBody());
            this.m_removeSkins.push(ba.getBody().userData.skin);
        };
        return strikeFixationBullet;
    }(py2Obj.basicObj));
    py2Obj.strikeFixationBullet = strikeFixationBullet;
    __reflect(strikeFixationBullet.prototype, "py2Obj.strikeFixationBullet");
})(py2Obj || (py2Obj = {}));
var DebugPlatform = (function () {
    function DebugPlatform() {
    }
    DebugPlatform.prototype.getUserInfo = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.login = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.activeShare = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.onshareMessage = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.showShareMenu = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.progress = function (value) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.submitScore = function (score, callback, thisObject) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.getRank = function (callback, thisObject) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.canPlayAd = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.playAd = function (callback) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    DebugPlatform.prototype.findShareQuery = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/];
            });
        });
    };
    return DebugPlatform;
}());
__reflect(DebugPlatform.prototype, "DebugPlatform", ["Platform"]);
if (!window.platform) {
    window.platform = new DebugPlatform();
}
var py2Obj;
(function (py2Obj) {
    var BoomProp = (function (_super) {
        __extends(BoomProp, _super);
        function BoomProp(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //玩家加分
            _this.pointList = [];
            _this.objkind = 401;
            return _this;
        }
        BoomProp.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        BoomProp.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("redball2_png");
            //	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            var body = world.createCircleBodyShape(skin.width >> 2, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        BoomProp.prototype.Destroy = function () {
            var goold = new Array();
            goold = py2Obj.PropManager.twoProp;
            if (goold.length > 0) {
                var length_1 = goold.length;
                for (var i = 0; i < length_1; i++) {
                    var jinbi = goold[0];
                    goold.splice(0, 1);
                    this.m_propManger.removePorp1(jinbi);
                }
            }
            else {
                this.m_propManger.removePorp1(this);
            }
            //this.m_propManger.removePorp1(this);
        };
        BoomProp.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 102 || otherBody.objkind == 104 || otherBody.objkind == 105) {
                // this.m_gamePanle.addPoint(this.m_point);
                // this.m_fb = <fakeBullet>otherBody;
                // var bullet = this.m_fb.runEnd();
                this.Destroy();
                //return bullet;
            }
        };
        return BoomProp;
    }(py2Obj.basicProp));
    py2Obj.BoomProp = BoomProp;
    __reflect(BoomProp.prototype, "py2Obj.BoomProp");
})(py2Obj || (py2Obj = {}));
//清空道具
var py2Obj;
(function (py2Obj) {
    var emptyProp = (function (_super) {
        __extends(emptyProp, _super);
        function emptyProp(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //玩家加分
            _this.pointList = [];
            _this.objkind = 403;
            return _this;
        }
        emptyProp.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        emptyProp.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("circle6_png");
            //	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            var body = world.createCircleBodyShape(skin.width >> 2, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        emptyProp.prototype.Destroy = function () {
            var goold = new Array();
            goold = py2Obj.PropManager.twoProp;
            if (goold.length > 0) {
                var length_2 = goold.length;
                for (var i = 0; i < length_2; i++) {
                    var jinbi = goold[0];
                    goold.splice(0, 1);
                    this.m_propManger.removePorp1(jinbi);
                }
            }
            else {
                this.m_propManger.removePorp1(this);
            }
            //	this.m_propManger.removePorp1(this);
        };
        emptyProp.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 102 || otherBody.objkind == 104 || otherBody.objkind == 105) {
                GameControl.GameControlSole.empty(); //清空所有刚体
                /**新手指导 */
                //	GameControl.GameControlSole.empty1();//如果场景里存在金币，清除金币
                this.Destroy();
            }
        };
        return emptyProp;
    }(py2Obj.basicProp));
    py2Obj.emptyProp = emptyProp;
    __reflect(emptyProp.prototype, "py2Obj.emptyProp");
})(py2Obj || (py2Obj = {}));
//重力道具
var py2Obj;
(function (py2Obj) {
    var gravityProp = (function (_super) {
        __extends(gravityProp, _super);
        function gravityProp(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //玩家加分
            _this.pointList = [];
            _this.objkind = 405;
            return _this;
        }
        gravityProp.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        gravityProp.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("zhong_png");
            //	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            var body = world.createCircleBodyShape(skin.width >> 2, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        gravityProp.prototype.Destroy = function () {
            var goold = new Array();
            goold = py2Obj.PropManager.twoProp;
            if (goold.length > 0) {
                var length_3 = goold.length;
                for (var i = 0; i < length_3; i++) {
                    var jinbi = goold[0];
                    goold.splice(0, 1);
                    this.m_propManger.removePorp1(jinbi);
                }
            }
            else {
                this.m_propManger.removePorp1(this);
            }
            //this.m_propManger.removePorp1(this);
        };
        gravityProp.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 102 || otherBody.objkind == 104 || otherBody.objkind == 105) {
                // this.m_gamePanle.addPoint(this.m_point);
                // this.m_fb = <fakeBullet>otherBody;
                // var bullet = this.m_fb.runEnd();
                this.Destroy();
                //return bullet;
            }
        };
        return gravityProp;
    }(py2Obj.basicProp));
    py2Obj.gravityProp = gravityProp;
    __reflect(gravityProp.prototype, "py2Obj.gravityProp");
})(py2Obj || (py2Obj = {}));
//金币道具
var py2Obj;
(function (py2Obj) {
    var IceProp = (function (_super) {
        __extends(IceProp, _super);
        function IceProp(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //玩家加分
            _this.pointList = [];
            _this.objkind = 400;
            return _this;
        }
        IceProp.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        IceProp.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("circle1_png");
            this.skinskin = skin;
            //	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            var body = world.createCircleBodyShape(this.skinskin.width / 4, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            skin.addEventListener(egret.Event.ENTER_FRAME, this.timerFunc1, this);
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            // shape.collisionMask=2;
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        IceProp.prototype.Destroy = function () {
            var goold = new Array();
            goold = py2Obj.PropManager.twoIce;
            if (goold.length > 0) {
                var length_4 = goold.length;
                for (var i = 0; i < length_4; i++) {
                    var jinbi = goold[0];
                    goold.splice(0, 1);
                    this.m_propManger.removePorp(jinbi);
                }
            }
            else {
                this.m_propManger.removePorp(this);
            }
        };
        IceProp.prototype.timerFunc1 = function () {
            // 	 GameControl.GameControlSole.textNumberTextNumber.x=this.skinskin.x-25;
            // 	 GameControl.GameControlSole.textNumberTextNumber.y=this.skinskin.y-80;
            if (GameControl.GameControlSole.Collidetime.shuzi == 0) {
                this.skinskin.scaleX = 1;
                this.skinskin.scaleY = 1;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 1) {
                this.skinskin.scaleX = 1.2;
                this.skinskin.scaleY = 1.2;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 2) {
                this.skinskin.scaleX = 1.4;
                this.skinskin.scaleY = 1.4;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 3) {
                this.skinskin.scaleX = 1.6;
                this.skinskin.scaleY = 1.6;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 4) {
                this.skinskin.scaleX = 1.8;
                this.skinskin.scaleY = 1.8;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 5) {
                this.skinskin.scaleX = 2;
                this.skinskin.scaleY = 2;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 6) {
                this.skinskin.scaleX = 2.2;
                this.skinskin.scaleY = 2.2;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 7) {
                this.skinskin.scaleX = 2.4;
                this.skinskin.scaleY = 2.4;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 8) {
                this.skinskin.scaleX = 2.6;
                this.skinskin.scaleY = 2.6;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 9) {
                this.skinskin.scaleX = 2.8;
                this.skinskin.scaleY = 2.8;
            }
            else if (GameControl.GameControlSole.Collidetime.shuzi == 10) {
                this.skinskin.scaleX = 3;
                this.skinskin.scaleY = 3;
            }
        };
        IceProp.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            var cishu;
            var objPoint = new egret.Point(this.m_body.position[0] + 20, this.m_body.position[1] + 20);
            // if (cishu < GameControl.GameControlSole.Collidetime.shuzi) {
            GameControl.GameControlSole.goldFrameAnimation(objPoint);
            // 	cishu++;
            // }
            //for (this.cishu = 0; this.cishu < GameControl.GameControlSole.Collidetime.shuzi; this.cishu++) {
            //} 
            //GameControl.GameControlSole.laserResult(this.m_body.position[0], this.m_body.position[1]);
            if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 105) {
                this.m_gamePanle.addPoint(this.m_point);
                // if(GameControl.GameControlSole.jiaQiuCount<=0)
                // {
                // 	this.m_fb = <fakeBullet>otherBody;
                //  var bullet = this.m_fb.runEnd();
                // }
                this.m_fb = otherBody;
                var bullet = this.m_fb.runEnd();
                this.Destroy();
                return bullet;
            }
            else if (otherBody.objkind == 102 || otherBody.objkind == 104) {
                this.m_gamePanle.addPoint(this.m_point);
                this.m_fb = otherBody;
                var bullet = this.m_fb.runEnd2();
                this.Destroy();
                return bullet;
            }
        };
        return IceProp;
    }(py2Obj.basicProp));
    py2Obj.IceProp = IceProp;
    __reflect(IceProp.prototype, "py2Obj.IceProp");
})(py2Obj || (py2Obj = {}));
//激光道具
var py2Obj;
(function (py2Obj) {
    var laserProp = (function (_super) {
        __extends(laserProp, _super);
        function laserProp(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //玩家加分
            _this.pointList = [];
            _this.objkind = 404;
            return _this;
        }
        laserProp.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        laserProp.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("ball_png");
            //	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            var body = world.createCircleBodyShape(skin.width >> 2, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        laserProp.prototype.Destroy = function () {
            var goold = new Array();
            goold = py2Obj.PropManager.twoProp;
            if (goold.length > 0) {
                var length_5 = goold.length;
                for (var i = 0; i < length_5; i++) {
                    var jinbi = goold[0];
                    goold.splice(0, 1);
                    this.m_propManger.removePorp1(jinbi);
                }
            }
            else {
                this.m_propManger.removePorp1(this);
            }
            //this.m_propManger.removePorp1(this);
        };
        laserProp.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 102 || otherBody.objkind == 104 || otherBody.objkind == 105) {
                GameControl.GameControlSole.laserResult(this.m_body.position[0], this.m_body.position[1]);
                // this.m_gamePanle.addPoint(this.m_point);
                // this.m_fb = <fakeBullet>otherBody;
                // var bullet = this.m_fb.runEnd();
                this.Destroy();
                //return bullet;
            }
        };
        return laserProp;
    }(py2Obj.basicProp));
    py2Obj.laserProp = laserProp;
    __reflect(laserProp.prototype, "py2Obj.laserProp");
})(py2Obj || (py2Obj = {}));
//变大道具
var py2Obj;
(function (py2Obj) {
    var magnify = (function (_super) {
        __extends(magnify, _super);
        function magnify(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //玩家加分
            _this.pointList = [];
            _this.objkind = 402;
            return _this;
        }
        magnify.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        magnify.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("circle4_png");
            //	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            var body = world.createCircleBodyShape(45, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        magnify.prototype.Destroy = function () {
            var goold = new Array();
            goold = py2Obj.PropManager.twoProp;
            if (goold.length > 0) {
                var length_6 = goold.length;
                for (var i = 0; i < length_6; i++) {
                    var jinbi = goold[0];
                    goold.splice(0, 1);
                    this.m_propManger.removePorp1(jinbi);
                }
            }
            else {
                this.m_propManger.removePorp1(this);
            }
            //this.m_propManger.removePorp1(this);
        };
        magnify.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 102 || otherBody.objkind == 104 || otherBody.objkind == 105) {
                // this.m_gamePanle.addPoint(this.m_point);
                // this.m_fb = <fakeBullet>otherBody;
                // var bullet = this.m_fb.runEnd();
                this.Destroy();
                //return bullet;
            }
        };
        return magnify;
    }(py2Obj.basicProp));
    py2Obj.magnify = magnify;
    __reflect(magnify.prototype, "py2Obj.magnify");
})(py2Obj || (py2Obj = {}));
//道具管理类用来管理生成的各种道具
//1.生成子弹图片
//2.更换子弹的刚体
//3.负责子弹的移动，或者给力
//4.负责子弹的停止
var py2Obj;
(function (py2Obj) {
    /**本地地图上所有道具 */
    var PropManager = (function (_super) {
        __extends(PropManager, _super);
        function PropManager(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            /** 用来存储所有的道具*/
            _this.allProps = [];
            _this.m_props = [];
            _this.m_props1 = [];
            _this.one2 = 0;
            _this.arr = [];
            _this.pointArr = []; //随机位置
            return _this;
        }
        PropManager.prototype.putPorpxinshou = function (tprop) {
            //	tprop.setPostion(x, y);
            //this.pointArr.splice(n, 1);
        };
        PropManager.prototype.putPorp = function (tprop) {
            if (tprop.objkind == 400) {
                if (this.pointArr.length <= 0) {
                    for (var i = 1; i <= 5; i++) {
                        for (var j = 1; j <= 5; j++) {
                            var x = (GameData.stageWidth / 5 * i) - 30;
                            var y = (GameData.stageHeight - 200) / 5 * j - 200;
                            if (y < 100) {
                                y = 100;
                            }
                            ;
                            if (y > 600) {
                                y = 600;
                            }
                            ;
                            var p = new egret.Point(x, y);
                            this.pointArr.push(p);
                        }
                    }
                }
                var n = Math.floor(Math.random() * this.pointArr.length);
                tprop.setPostion(this.pointArr[n].x, this.pointArr[n].y);
                this.pointArr.splice(n, 1);
            }
            //body.angle = (-Math.random() * Math.PI / 4) + (Math.random() * Math.PI / 4);
        };
        PropManager.prototype.putProp2 = function (tprop) {
            if (this.pointArr.length <= 0) {
                for (var i = 1; i <= 5; i++) {
                    for (var j = 1; j <= 5; j++) {
                        var x = (GameData.stageWidth / 5 * i) - 30;
                        var y = (GameData.stageHeight - 200) / 5 * j; //200
                        if (y < 100) {
                            y = 100;
                        }
                        ;
                        if (y > 600) {
                            y = 600;
                        }
                        ;
                        var p = new egret.Point(x, y);
                        this.pointArr.push(p);
                    }
                }
            }
            var n = Math.floor(Math.random() * this.pointArr.length);
            tprop.setPostion(this.pointArr[n].x, this.pointArr[n].y);
            this.pointArr.splice(n, 1);
        };
        PropManager.prototype.removePorp = function (ba) {
            var index = this.m_props.indexOf(ba);
            if (index > -1) {
                this.m_props.splice(index, 1);
            }
            else {
                return;
            }
            this.m_removeSkins.push(ba.getBody().userData.skin);
            this.m_world.removeBodys.push(ba.getBody());
            if (PropManager.twoIce.length > 0) {
                return;
            }
            else {
                //	this.createProp();//原来的
                //this.createPropXinShou();//新手引导
            }
        };
        PropManager.prototype.removePorp1 = function (ba) {
            var index = this.m_props1.indexOf(ba);
            if (index > -1) {
                this.m_props1.splice(index, 1);
            }
            else {
                return;
            }
            this.m_removeSkins.push(ba.getBody().userData.skin);
            this.m_world.removeBodys.push(ba.getBody());
            if (PropManager.twoProp.length > 0) {
                return;
            }
            else {
                //	this.createProp();//原来的
                //this.createPropXinShou();//新手引导
            }
        };
        //根据玩家的等级来创建一个或者多个道具
        //新手引导
        PropManager.prototype.createPropXinShou = function () {
            if (GameControl.GameControlSole.count < 50) {
                var prop;
                var shuzu = [];
                shuzu = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
                //var one = Math.floor(Math.random() * shuzu.length);
                if (this.one2 < 8) {
                    this.one2 += 1;
                    var count2 = shuzu[this.one2];
                    if (count2 == 1 || count2 == 4 || count2 == 8) {
                        prop = new py2Obj.laserProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        this.putProp2(prop);
                        prop.setPostion(500, 500);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                    }
                    else if (count2 == 5) {
                        prop = new py2Obj.magnify(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        //	this.putProp2(prop);
                        //	this.putPorpxinshou(prop);
                        prop.setPostion(450, 450);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                    }
                    else if (count2 == 3) {
                        prop = new py2Obj.BoomProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        prop.setPostion(200, 150);
                        //this.putProp2(prop);
                        //	this.putPorpxinshou(prop);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                    }
                    else if (count2 == 7) {
                        prop = new py2Obj.gravityProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        //this.putProp2(prop);
                        //this.putPorpxinshou(prop);
                        prop.setPostion(500, 200);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                    }
                    else if (count2 == 6) {
                        prop = new py2Obj.strikeProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        //this.putProp2(prop);
                        //	this.putPorpxinshou(prop);
                        prop.setPostion(230, 400);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                    }
                    else if (count2 == 2) {
                        var prop;
                        prop = new py2Obj.IceProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        prop.setPostion(200, 300); //333333
                        //this.putPorp(prop);
                        this.m_props.push(prop);
                        this.allProps.push(prop);
                    }
                }
                else {
                    this.createProp();
                }
            }
        }; //新手引导
        PropManager.prototype.createProp = function () {
            var suiji = Math.floor(Math.random() * 10);
            if (GameControl.GameControlSole.count < 50) {
                var prop;
                var shuzu = [];
                shuzu = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
                var one = Math.floor(Math.random() * shuzu.length);
                var count2 = shuzu[one];
                console.log("Count:" + count);
                if (count2 == 1) {
                    prop = new py2Obj.laserProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count2 == 3) {
                    prop = new py2Obj.magnify(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count2 == 5) {
                    prop = new py2Obj.BoomProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count2 == 7) {
                    prop = new py2Obj.gravityProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count2 == 9) {
                    prop = new py2Obj.strikeProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else {
                    var prop;
                    prop = new py2Obj.IceProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putPorp(prop);
                    this.m_props.push(prop);
                    this.allProps.push(prop);
                }
            }
            else if (GameControl.GameControlSole.count >= 50 && GameControl.GameControlSole.count < 80) {
                var prop;
                var shuzu = [];
                shuzu = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
                var one = Math.floor(Math.random() * shuzu.length);
                var count1 = shuzu[one];
                if (count1 == 1) {
                    prop = new py2Obj.laserProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count1 == 3) {
                    prop = new py2Obj.magnify(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count1 == 5) {
                    prop = new py2Obj.BoomProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count1 == 7) {
                    prop = new py2Obj.gravityProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else if (count1 == 9) {
                    prop = new py2Obj.strikeProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putProp2(prop);
                    this.m_props1.push(prop);
                    this.allProps.push(prop);
                }
                else {
                    var prop;
                    prop = new py2Obj.IceProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                    prop.init();
                    prop.m_propManger = this;
                    this.putPorp(prop);
                    this.m_props.push(prop);
                    this.allProps.push(prop);
                }
            }
            if (GameControl.GameControlSole.count >= 80) {
                var num777 = Math.floor(Math.random() * 10);
                PropManager.twoIce.splice(0, PropManager.twoIce.length);
                if (num777 < 8) {
                    //if (level == 1) {//创建普通道具
                    var count;
                    if (PropManager.twoIce.length < 2) {
                        var prop;
                        prop = new py2Obj.IceProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        this.putPorp(prop);
                        this.m_props.push(prop);
                        this.allProps.push(prop);
                        PropManager.twoIce.push(prop);
                        var prop1;
                        prop1 = new py2Obj.IceProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop1.init();
                        prop1.m_propManger = this;
                        this.putPorp(prop1);
                        this.m_props.push(prop1);
                        this.allProps.push(prop1);
                        PropManager.twoIce.push(prop1);
                        var aa = PropManager.twoIce;
                    }
                }
                else if (num777 >= 8) {
                    var prop;
                    var shuzu = [];
                    shuzu = [1, 3, 5, 7, 9];
                    var one = Math.floor(Math.random() * shuzu.length);
                    var count11 = shuzu[one];
                    if (count11 == 1) {
                        prop = new py2Obj.laserProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        this.putProp2(prop);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                        PropManager.twoProp.push(prop);
                    }
                    else if (count11 == 3) {
                        prop = new py2Obj.magnify(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        this.putProp2(prop);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                        PropManager.twoProp.push(prop);
                    }
                    else if (count11 == 5) {
                        prop = new py2Obj.BoomProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        this.putProp2(prop);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                        PropManager.twoProp.push(prop);
                    }
                    else if (count11 == 7) {
                        prop = new py2Obj.gravityProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        this.putProp2(prop);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                        PropManager.twoProp.push(prop);
                    }
                    else if (count11 == 9) {
                        prop = new py2Obj.strikeProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop.init();
                        prop.m_propManger = this;
                        this.putProp2(prop);
                        this.m_props1.push(prop);
                        this.allProps.push(prop);
                        PropManager.twoProp.push(prop);
                    }
                    var prop1;
                    var shuzu = [];
                    shuzu = [1, 3, 5, 7, 9];
                    var two = Math.floor(Math.random() * shuzu.length);
                    var count12 = shuzu[two];
                    if (count12 == 1) {
                        prop1 = new py2Obj.laserProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop1.init();
                        prop1.m_propManger = this;
                        this.putProp2(prop1);
                        this.m_props1.push(prop1);
                        this.allProps.push(prop1);
                        PropManager.twoProp.push(prop1);
                    }
                    else if (count12 == 3) {
                        prop1 = new py2Obj.magnify(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop1.init();
                        prop1.m_propManger = this;
                        this.putProp2(prop1);
                        this.m_props1.push(prop1);
                        this.allProps.push(prop1);
                        PropManager.twoProp.push(prop1);
                    }
                    else if (count12 == 5) {
                        prop1 = new py2Obj.BoomProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop1.init();
                        prop1.m_propManger = this;
                        this.putProp2(prop1);
                        this.m_props1.push(prop1);
                        this.allProps.push(prop1);
                        PropManager.twoProp.push(prop1);
                    }
                    else if (count12 == 7) {
                        prop1 = new py2Obj.gravityProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop1.init();
                        prop1.m_propManger = this;
                        this.putProp2(prop1);
                        this.m_props1.push(prop1);
                        this.allProps.push(prop1);
                        PropManager.twoProp.push(prop1);
                    }
                    else if (count12 == 9) {
                        prop1 = new py2Obj.strikeProp(this.m_world, this.m_gamePanle, this.m_removeSkins);
                        prop1.init();
                        prop1.m_propManger = this;
                        this.putProp2(prop1);
                        this.m_props1.push(prop1);
                        this.allProps.push(prop1);
                        PropManager.twoProp.push(prop1);
                    }
                }
            }
        };
        PropManager.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        PropManager.prototype.createMyRigidbody = function () {
            return null;
        };
        //玩家加分
        PropManager.twoIce = [];
        PropManager.twoProp = [];
        return PropManager;
    }(py2Obj.basicObj));
    py2Obj.PropManager = PropManager;
    __reflect(PropManager.prototype, "py2Obj.PropManager");
})(py2Obj || (py2Obj = {}));
// 触发道具
var py2Obj;
(function (py2Obj) {
    var strikeProp = (function (_super) {
        __extends(strikeProp, _super);
        function strikeProp(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //玩家加分
            _this.pointList = [];
            _this.objkind = 406;
            return _this;
        }
        strikeProp.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        strikeProp.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("chu_png");
            //	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            var body = world.createCircleBodyShape(skin.width >> 2, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        strikeProp.prototype.Destroy = function () {
            var goold = new Array();
            goold = py2Obj.PropManager.twoProp;
            if (goold.length > 0) {
                var length_7 = goold.length;
                for (var i = 0; i < length_7; i++) {
                    var jinbi = goold[0];
                    goold.splice(0, 1);
                    this.m_propManger.removePorp1(jinbi);
                }
            }
            else {
                this.m_propManger.removePorp1(this);
            }
            //this.m_propManger.removePorp1(this);
        };
        strikeProp.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 102 || otherBody.objkind == 104 || otherBody.objkind == 105) {
                // this.m_gamePanle.addPoint(this.m_point);
                // this.m_fb = <fakeBullet>otherBody;
                // var bullet = this.m_fb.runEnd();
                this.Destroy();
                //return bullet;
            }
        };
        return strikeProp;
    }(py2Obj.basicProp));
    py2Obj.strikeProp = strikeProp;
    __reflect(strikeProp.prototype, "py2Obj.strikeProp");
})(py2Obj || (py2Obj = {}));
//墙体基本类基础类(10 开始)
//1.生成子弹图片
//2.更换子弹的刚体
//3.负责子弹的移动，或者给力
//4.负责子弹的停止
var py2Obj;
(function (py2Obj) {
    var basicWall = (function (_super) {
        __extends(basicWall, _super);
        //保存外部的物理世界
        function basicWall(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.objkind = 200;
            return _this;
        }
        basicWall.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        basicWall.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("left_png");
            var body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            // shape.collisionMask=2;
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        basicWall.prototype.getCollision = function (otherBody) {
            if (otherBody.objkind == 100) {
                this.m_removeSkins.push(otherBody.getBody().userData.skin);
                this.m_world.removeBodys.push(otherBody);
            }
            return;
        };
        return basicWall;
    }(py2Obj.basicObj));
    py2Obj.basicWall = basicWall;
    __reflect(basicWall.prototype, "py2Obj.basicWall");
})(py2Obj || (py2Obj = {}));
//墙体基本类基础类(10 开始)
//1.生成子弹图片
//2.更换子弹的刚体
//3.负责子弹的移动，或者给力
//4.负责子弹的停止
var py2Obj;
(function (py2Obj) {
    var bottomWall = (function (_super) {
        __extends(bottomWall, _super);
        //保存外部的物理世界
        function bottomWall(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.objkind = 201;
            return _this;
        }
        bottomWall.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        bottomWall.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("topLine_png");
            var body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            // shape.collisionMask=2;
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        return bottomWall;
    }(py2Obj.basicObj));
    py2Obj.bottomWall = bottomWall;
    __reflect(bottomWall.prototype, "py2Obj.bottomWall");
})(py2Obj || (py2Obj = {}));
// TypeScript file
var py2Obj;
(function (py2Obj) {
    var qiu = (function (_super) {
        __extends(qiu, _super);
        //保存外部的物理世界
        function qiu(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.objkind = 500;
            return _this;
        }
        qiu.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        qiu.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("ball_png");
            var body = world.createCircleBodyShape(13, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            // shape.collisionMask=2;
            shape.collisionMask = 6;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        return qiu;
    }(py2Obj.basicObj));
    py2Obj.qiu = qiu;
    __reflect(qiu.prototype, "py2Obj.qiu");
})(py2Obj || (py2Obj = {}));
var py2Obj;
(function (py2Obj) {
    var zhuanWall = (function (_super) {
        __extends(zhuanWall, _super);
        function zhuanWall(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            //保存外部的物理世界
            _this.pointList = [];
            _this.objkind = 600;
            return _this;
        }
        zhuanWall.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        zhuanWall.prototype.createMyRigidbody = function () {
            //this.bool=true;
            var world = this.m_world;
            var skin = this.createSkin("蓝色砖块_png");
            var body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            //	shape.collisionGroup = 2;//010与001为0，010与110为1
            shape.collisionMask = 6;
            //this.label.x = this.m_body.position[0];
            //this.label.y = this.m_body.position[1];
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        zhuanWall.prototype.getCollision = function (otherBody) {
            _super.prototype.getCollision.call(this, otherBody);
            // if (otherBody.objkind == 103) {	
            // 	this.removebullet(this);
            // }
        };
        zhuanWall.prototype.removeBasicbullet = function (ba) {
            this.m_world.removeBodys.push(ba.getBody());
            this.m_removeSkins.push(ba.getBody().userData.skin);
        };
        return zhuanWall;
    }(py2Obj.basicObj));
    py2Obj.zhuanWall = zhuanWall;
    __reflect(zhuanWall.prototype, "py2Obj.zhuanWall");
})(py2Obj || (py2Obj = {}));
var control;
(function (control) {
    var ControlBasic = (function () {
        function ControlBasic(stage) {
            this.stage = stage;
        }
        /** 打开事件*/
        ControlBasic.prototype.open = function () {
            this.close();
            this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
        };
        /** 关闭事件*/
        ControlBasic.prototype.close = function () {
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
        };
        ControlBasic.prototype.onTouch = function (e) {
            var BTN = e.target;
            switch (e.type) {
                case egret.TouchEvent.TOUCH_BEGIN:
                    if (BTN.blendMode == "normal") {
                        // this.clickShare();
                    }
                    else {
                        this.posStart = new egret.Point(e.stageX, e.stageY);
                        this.controlStart();
                    }
                    break;
                case egret.TouchEvent.TOUCH_MOVE:
                    this.posMove = new egret.Point(e.stageX, e.stageY);
                    this.controlMove();
                    break;
                case egret.TouchEvent.TOUCH_END:
                    this.posEnd = new egret.Point(e.stageX, e.stageY);
                    this.controlEnd();
                    break;
            }
        };
        /** 手指按下*/
        ControlBasic.prototype.controlStart = function () {
            if (this.startBackFun != null) {
                this.startBackFun(this.posStart);
            }
            this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
            this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
        };
        /** 手指移动*/
        ControlBasic.prototype.controlMove = function () {
            if (this.moveBackFun != null) {
                this.moveBackFun(this.posMove);
            }
        };
        /** 手指离开*/
        ControlBasic.prototype.controlEnd = function () {
            if (this.endBackFun != null) {
                this.endBackFun(this.posEnd);
            }
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
            this.stage.removeEventListener(egret.TouchEvent.ADDED_TO_STAGE, this.moveBackFun, this);
        };
        return ControlBasic;
    }());
    control.ControlBasic = ControlBasic;
    __reflect(ControlBasic.prototype, "control.ControlBasic");
    /**
     * @author vinson
     * 创建时间：2017-12-28 上午9:36:42
     * 控制杆自由控制移动
     */
    var ControlBarMove = (function (_super) {
        __extends(ControlBarMove, _super);
        function ControlBarMove(stage, controlBar, controlBg) {
            var _this = _super.call(this, stage) || this;
            _this.controlBar = controlBar;
            _this.controlBg = controlBg;
            return _this;
        }
        /** 手指按下*/
        ControlBarMove.prototype.controlStart = function () {
            if (this.controlBar.hitTestPoint(this.posStart.x, this.posStart.y)) {
                _super.prototype.controlStart.call(this);
                this.isDrag = true;
            }
        };
        ControlBarMove.prototype.controlMove = function () {
            if (this.isDrag == false)
                return;
            var x = this.posMove.x, y = this.posMove.y;
            var bg = this.controlBg;
            var bar = this.controlBar;
            var cx = bg.x;
            var cy = bg.y;
            var dx = x - cx;
            var dy = y - cy;
            var ds = Math.sqrt(dx * dx + dy * dy);
            var r = bg.width >> 1;
            var conA = dx / ds;
            var sinA = dy / ds;
            if (ds < r) {
                bar.x = x;
                bar.y = y;
            }
            else {
                bar.x = cx + conA * r;
                bar.y = cy + sinA * r;
            }
            if (this.moveBackFun != null) {
                var value = new egret.Point(bar.x - bg.x, bar.y - bg.y);
                this.moveBackFun(value);
            }
        };
        ControlBarMove.prototype.controlEnd = function () {
            this.isDrag = false;
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
            var bg = this.controlBg;
            var bar = this.controlBar;
            bar.x = bg.x;
            bar.y = bg.y;
            if (this.endBackFun != null) {
                this.endBackFun(this.posEnd);
            }
        };
        return ControlBarMove;
    }(ControlBasic));
    control.ControlBarMove = ControlBarMove;
    __reflect(ControlBarMove.prototype, "control.ControlBarMove");
    /**
     * @author vinson
     * 创建时间：2017-12-28 上午9:36:42
     * 手指滑动，向上向下向左向右滑动
     */
    var ControlFingerMove = (function (_super) {
        __extends(ControlFingerMove, _super);
        function ControlFingerMove(stage) {
            return _super.call(this, stage) || this;
        }
        ControlFingerMove.prototype.controlEnd = function () {
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouch, this);
            this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
            var disx = this.posEnd.x - this.posStart.x;
            var disy = this.posEnd.y - this.posStart.y;
            var value = new egret.Point(0, 0);
            if (Math.abs(disx) > Math.abs(disy)) {
                value.x = disx > 0 ? 1 : -1;
            }
            else {
                value.y = disy > 0 ? 1 : -1;
            }
            if (this.endBackFun != null) {
                this.endBackFun(this.posEnd);
            }
            if (this.moveEndBackFun != null) {
                this.moveEndBackFun(value);
            }
        };
        return ControlFingerMove;
    }(ControlBasic));
    control.ControlFingerMove = ControlFingerMove;
    __reflect(ControlFingerMove.prototype, "control.ControlFingerMove");
    /**
     * @author vinson
     * 创建时间：2017-12-28 上午9:36:42
     * 可示对象自由拖动
     */
    var ControlDrag = (function (_super) {
        __extends(ControlDrag, _super);
        function ControlDrag(stage, display) {
            var _this = _super.call(this, stage) || this;
            _this.display = display;
            _this.distance = new egret.Point;
            return _this;
        }
        Object.defineProperty(ControlDrag.prototype, "target", {
            set: function (value) {
                this.display = value;
            },
            enumerable: true,
            configurable: true
        });
        ControlDrag.prototype.controlStart = function () {
            if (this.display.hitTestPoint(this.posStart.x, this.posStart.y)) {
                _super.prototype.controlStart.call(this);
                this.isDrag = true;
                this.distance.x = this.posStart.x - this.display.x;
                this.distance.y = this.posStart.y - this.display.y;
            }
        };
        ControlDrag.prototype.controlMove = function () {
            if (this.isDrag) {
                _super.prototype.controlMove.call(this);
                this.display.x = this.posMove.x - this.distance.x;
                this.display.y = this.posMove.y - this.distance.y;
            }
        };
        ControlDrag.prototype.controlEnd = function () {
            this.isDrag = false;
            _super.prototype.controlEnd.call(this);
            if (this.endBackFun != null) {
                this.endBackFun();
            }
        };
        return ControlDrag;
    }(ControlBasic));
    control.ControlDrag = ControlDrag;
    __reflect(ControlDrag.prototype, "control.ControlDrag");
    /**
     * @author vinson
     * 创建时间：2017-12-28 上午9:36:42
     * 多点按下与松开的触控管理
     */
    var ControlMoreTab = (function (_super) {
        __extends(ControlMoreTab, _super);
        /**datas:[{display:display:backCall:backCall}]*/
        function ControlMoreTab(stage, datas) {
            var _this = _super.call(this, stage) || this;
            _this.nodes = [];
            for (var i = 0; i < datas.length; i++) {
                var obj = datas[i];
                var node = new MorePointNode(obj.display, obj.backCall);
                _this.nodes.push(node);
            }
            return _this;
        }
        ControlMoreTab.prototype.onTouch = function (e) {
            this.id = e.touchPointID;
            _super.prototype.onTouch.call(this, e);
        };
        ControlMoreTab.prototype.check = function (x, y, type) {
            var nodes = this.nodes;
            for (var i = 0; i < nodes.length; i++) {
                var node = nodes[i];
                if (type == 1) {
                    if (node.display.hitTestPoint(x, y)) {
                        node.id = this.id;
                        node.backCall(type);
                    }
                }
                else {
                    if (node.id == this.id) {
                        node.id = -1;
                        node.backCall(type);
                    }
                }
            }
        };
        ControlMoreTab.prototype.controlStart = function () {
            this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouch, this);
            this.check(this.posStart.x, this.posStart.y, 1);
        };
        ControlMoreTab.prototype.controlEnd = function () {
            _super.prototype.controlEnd.call(this);
            this.check(this.posEnd.x, this.posEnd.y, 0);
        };
        return ControlMoreTab;
    }(ControlBasic));
    control.ControlMoreTab = ControlMoreTab;
    __reflect(ControlMoreTab.prototype, "control.ControlMoreTab");
    var MorePointNode = (function () {
        function MorePointNode(display, backCall) {
            this.display = display;
            this.backCall = backCall;
        }
        return MorePointNode;
    }());
    control.MorePointNode = MorePointNode;
    __reflect(MorePointNode.prototype, "control.MorePointNode");
})(control || (control = {}));
var MUSIC_CLICK_BTN = "click_mp3"; //按钮
var MUSIC_HIT = "hit_mp3";
var MUSIC_ADDNUM = "addNum_mp3";
var MUSIC_FIRE = "fire_mp3"; //发射
var MUSIC_FLOOR = "floor_mp3";
var MUSIC_BG = "background_mp3"; //背景
var MUSIC_CL = "ct_mp3"; //激光
var MUSIC_BaoZha = "Baozha_mp3"; //爆炸
var MUSIC_Jinbi = "Jinbi_mp3"; //金币
var MUSIC_Eatdaoju = "EatDaoju_mp3"; //金币
var tishi = 9;
var tanChuang = 0;
var EVENT_FIRE = "event fire";
var EVENT_REMOVE = "event remove";
var TYPE_HAND = "type hand";
var ICON_ADD = "addIcon_png";
var SHAPE = { rect: "rect", circle: "circle" }; //形状
var OVER_DIS = 200;
var lizitexiao;
(function (lizitexiao) {
    lizitexiao[lizitexiao[" "] = 0] = " ";
    lizitexiao[lizitexiao["ball_png"] = 1] = "ball_png";
    lizitexiao[lizitexiao["chu_png"] = 2] = "chu_png";
    lizitexiao[lizitexiao["purpleBall_png"] = 3] = "purpleBall_png";
    lizitexiao[lizitexiao["zhong_png"] = 4] = "zhong_png";
    lizitexiao[lizitexiao["redball2_png"] = 5] = "redball2_png";
})(lizitexiao || (lizitexiao = {}));
var GameControl = (function (_super) {
    __extends(GameControl, _super);
    function GameControl() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.tishi2 = 0;
        _this.isdisplay = false;
        _this.isChanger = 0;
        _this.shareNum = 0;
        /**死亡时变量 */
        _this.overValue = 0;
        _this.isOver = 0;
        _this.boomNum = 0;
        /**与球触碰的线 */
        _this.shape1 = new egret.Shape();
        /**储存场景所有静止的子弹 */
        _this.my_ball = [];
        _this.my_strikeBall = [];
        _this.my_peng = [];
        _this.my_chuchun = []; //储存子弹
        _this.my_chuchun2 = [];
        /**未与球触碰的线 */
        _this.shape = new egret.Shape();
        _this.names = []; //数字刚体皮肤名字
        _this.propCount = 0; //反弹后获得道具数量
        _this.removeSkins = []; //需要删除刚体的皮肤
        _this.moveNum = 0; //数字刚体可移动次数
        _this.ballNum = 0; //发球数量
        _this.minBodyCount = 1; //数字刚体的最少数值
        _this.zhuobiao = null; //坐标
        _this.fashezhuo = null;
        _this.panshu = 0; //第一次运行
        _this.playpd = false; //齿轮音
        /**限制数 */
        _this.restrictNumber = 0;
        _this.NowBullet1 = null;
        _this.time = 0;
        /**线发光控制按钮*/
        _this.fenxiang = true;
        _this.faguang = false;
        _this.e = 13; //距离
        _this.isFire = false;
        _this.shu11 = 0; //计数
        _this.sffaqiu = false;
        /**分数 */
        _this.count = 0;
        /**道具 */
        _this.m_PropManager = null; //普通加分
        _this.yinxiaoBool = false;
        /**发射按钮的点击按键 */
        _this.fashe2 = false; //发射按钮
        _this.jiaQiuCount = 0;
        /**关卡数字*/
        _this.upgradeNumber = 1;
        _this.upgradeNumber2 = 0;
        _this.upgradeNumber3 = 0;
        _this.upgradeNumber4 = 0;
        _this.jinbicishu = 0;
        _this.daojucishu = 0;
        _this.daojutishi = 0;
        _this.BaozhaCount = 0;
        _this.ChufaCount = 0;
        _this.ZhongliCount = 0;
        _this.FangdaCount = 0;
        _this.Weitiaojuli = 0; //微调距离
        /**回合计数 */
        _this.huiheNum = 0;
        /**回合判断 */
        _this.istop = false;
        _this.playOneHp = 5;
        _this.playTwoHp = 5;
        /**加分显示分本数字*/
        _this.shuzishuzi = 0;
        return _this;
    }
    GameControl.prototype.render = function () {
        _super.prototype.render.call(this);
        // GameData.stageHeight = this.stageHeight;
        // GameData.stageWidth = this.stageWidth;
        // SoundControl.getIns().addItem(MUSIC_HIT);
        // SoundControl.getIns().addItem(MUSIC_ADDNUM);
        // SoundControl.getIns().addItem(MUSIC_FIRE);
        // SoundControl.getIns().addItem(MUSIC_FLOOR);
        // SoundControl.getIns().addItem(MUSIC_BG, true);
        // SoundControl.getIns().play(MUSIC_BG, 0, 9999);
        // platform.findShareQuery(this.shengyin);
        this.createImageBg("BG_png");
        var time1 = new egret.Timer(500, 0);
        // time1.start();
        time1.addEventListener(egret.TimerEvent.TIMER, this.playcl1, this);
        /*发射按钮*/
        this.fashe = new MImage("小轮_png");
        this.addChild(this.fashe);
        this.fashe.x = 500;
        this.fashe.y = 900;
        this.fashe.scaleX = 0.5;
        this.fashe.scaleY = 0.5;
        /**当前子弹图片 */
        this.nowBulletImg = new MImage("ball_png");
        this.addChild(this.nowBulletImg);
        this.nowBulletImg.x = 505;
        this.nowBulletImg.y = 905;
        this.nowBulletImgBule = new MImage("purpleBall_png");
        this.addChild(this.nowBulletImgBule);
        this.nowBulletImgBule.x = 505;
        this.nowBulletImgBule.y = 905;
        this.nowBulletImgBule.visible = false;
        /*微调按钮*/ //改为切换子弹按钮
        this.adjustment = new MImage("小轮_png");
        this.addChild(this.adjustment);
        this.adjustment.x = 500;
        this.adjustment.y = 1000;
        this.adjustment.scaleX = 0.5;
        this.adjustment.scaleY = 0.5;
        this.adjustment.touchEnabled = true;
        //egret.Tween.get(this.adjustment,{loop:true}).to({alpha:0},300).to({alpha:1},300);
        /** */
        /**新手指导 */
        this.Newarrow = new MImage("arrow_png"); //发射按钮的指示箭头
        // this.addChild(this.Newarrow);
        this.Newarrow.x = 440;
        this.Newarrow.y = 790;
        this.Newarrow.scaleX = 0.5;
        this.Newarrow.scaleY = 1;
        this.Newarrow.rotation = -35;
        this.Newarrow1 = new MImage("arrow_png"); //微调按钮的指示箭头
        //  this.addChild(this.Newarrow1);
        this.upgradeNumber4 = 1; //新手引导
        this.Newarrow1.x = 400;
        this.Newarrow1.y = 1150;
        this.Newarrow1.scaleX = 0.5;
        this.Newarrow1.scaleY = 1;
        this.Newarrow1.rotation = 250;
        this.Newjiantou = new MImage("jiantou_png");
        // this.Newjiantou.x = 500;
        // this.Newjiantou.y = 500;
        this.Newjiantou.scaleX = 0.3;
        this.Newjiantou.scaleY = 0.3;
        // this.addChild(this.Newjiantou);
        this.addChild(this.Newarrow1);
        this.addChild(this.Newarrow);
        this.Newarrow.visible = false;
        this.Newarrow1.visible = false;
        //  egret.Tween.get(this.Newarrow1, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁
        // egret.localStorage.setItem("xinshouyindao", "false");//新手指导微信存储
        // console.log("是水电费不回去服务收费" + egret.localStorage.getItem("xinshouyindao"));
        //this.Newarrow1.visible = true;
        //  if (tishi == 0 && egret.localStorage.getItem("xinshouyindao") == "false") {
        //  if (egret.localStorage.getItem("xinshouyindao") == "false") {
        if (tishi < 9) {
            this.upgradeNumber2 = 100;
            //    if (egret.localStorage.getItem("xinshouyindao") == "false") {
            this.UpgradeTishi();
        }
        else {
            this.removeChild(this.Newarrow);
            this.removeChild(this.Newarrow1);
            //  this.bulletMax = 10;
            tishi = 9; //不走新手引导
        }
        /**新手指导 存取数据 */
        // if (egret.localStorage.getItem("xinshouyindao") == "true") {
        //     this.removeChild(this.Newarrow);
        //     this.removeChild(this.Newarrow1);
        // }
        //  }
        //    else
        //    {
        //        return ;
        //    }
        // var bj = new MImage("startPanel1_png");
        // this.bj = bj;
        // var btn: MButton = new MButton(new MImage("jixu_png"), new MImage("jixu_png"));
        // this.btn = btn;
        // btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
        // btn.x = (this.stageWidth - btn.width) >> 1;
        // btn.y = 650;
        // var upgradeText: egret.TextField = new egret.TextField();
        // upgradeText.width = 400;
        // upgradeText.height = 400;
        // upgradeText.x = 140;
        // upgradeText.y = 400;
        // upgradeText.textColor = 0x00c4a851;
        // upgradeText.size = 32;
        // upgradeText.textAlign = egret.HorizontalAlign.CENTER;
        // this.upgradeNumber3 = 1;//防止弹出界面同时出现
        // upgradeText.text = "点击发射按钮"
        // bj.addChild(upgradeText);
        // this.addChild(this.bj);
        // this.addChild(this.fashe);//新手引导
        // // this.Newarrow.visible = true;
        // this.Newarrow1.visible = false;
        // //egret.Tween.get(this.Newarrow,{loop:true}).to({ alpha: 0}, 200).to({ alpha: 1}, 200); //颜色闪烁    
        // //egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        // // Tween.get(this.Newarrow).to({alpha:1},500);
        //微调轮盘
        this.faan = new MImage("大轮1_png");
        this.addChild(this.faan);
        this.faan.anchorOffsetX = this.faan.width >> 1;
        this.faan.anchorOffsetY = this.faan.height >> 1;
        this.faan.x = 320;
        this.faan.y = 880;
        this.faan.scaleX = 1.2;
        this.faan.scaleY = 1.2;
        this.xiaofaan = new MImage("小轮_png");
        this.addChild(this.xiaofaan);
        this.xiaofaan.anchorOffsetX = this.xiaofaan.width >> 1;
        this.xiaofaan.anchorOffsetY = this.xiaofaan.height >> 1;
        this.xiaofaan.x = 320;
        this.xiaofaan.y = 950;
        this.xiaofaan.scaleY = 0.5;
        this.xiaofaan.scaleX = 0.5;
        this.xiaoluntop = new MImage("小轮_png");
        this.addChild(this.xiaoluntop);
        this.xiaoluntop.anchorOffsetX = this.xiaoluntop.width >> 1;
        this.xiaoluntop.anchorOffsetY = this.xiaoluntop.height >> 1;
        this.xiaoluntop.x = 320;
        this.xiaoluntop.y = 130;
        this.xiaoluntop.scaleY = 0.5;
        this.xiaoluntop.scaleX = 0.5;
        //触发球 
        this.chufa = new MImage("chu_png");
        this.addChild(this.chufa);
        this.chufa.anchorOffsetX = this.chufa.width >> 1;
        this.chufa.anchorOffsetY = this.chufa.height >> 1;
        this.chufa.x = 210;
        this.chufa.y = 1010;
        this.Textchufa = this.createText(0, 0, "0");
        this.Textchufa.textColor = 0x000000;
        this.Textchufa.size = 30;
        this.Textchufa.x = this.chufa.x - 7;
        this.Textchufa.y = this.chufa.y - 14;
        this.chufa.touchEnabled = true;
        this.chufa.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ChufaClick, this);
        //放大球
        this.fangda = new MImage("purpleBall_png");
        this.addChild(this.fangda);
        this.fangda.anchorOffsetX = this.fangda.width >> 1;
        this.fangda.anchorOffsetY = this.fangda.height >> 1;
        this.fangda.x = 280;
        this.fangda.y = 1010;
        this.fangda.scaleX = 1.5;
        this.fangda.scaleY = 1.5;
        this.Textfangda = this.createText(0, 0, "0");
        this.Textfangda.textColor = 0x000000;
        this.Textfangda.size = 30;
        this.Textfangda.x = this.fangda.x - 7;
        this.Textfangda.y = this.fangda.y - 14;
        this.fangda.touchEnabled = true;
        this.fangda.addEventListener(egret.TouchEvent.TOUCH_TAP, this.FangdaClick, this);
        //重力球 
        this.zhongli = new MImage("zhong_png");
        this.addChild(this.zhongli);
        this.zhongli.anchorOffsetX = this.zhongli.width >> 1;
        this.zhongli.anchorOffsetY = this.zhongli.height >> 1;
        this.zhongli.x = 350;
        this.zhongli.y = 1010;
        this.Textzhongli = this.createText(0, 0, "0");
        this.Textzhongli.textColor = 0x000000;
        this.Textzhongli.size = 30;
        this.Textzhongli.x = this.zhongli.x - 7;
        this.Textzhongli.y = this.zhongli.y - 14;
        this.zhongli.touchEnabled = true;
        this.zhongli.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ZhongliClick, this);
        //爆炸球 
        this.baozha = new MImage("redball2_png");
        this.addChild(this.baozha);
        this.baozha.anchorOffsetX = this.baozha.width >> 1;
        this.baozha.anchorOffsetY = this.baozha.height >> 1;
        this.baozha.x = 420;
        this.baozha.y = 1010;
        this.baozha.scaleX = 1.5;
        this.baozha.scaleY = 1.5;
        this.Textbaozha = this.createText(0, 0, "0");
        this.Textbaozha.textColor = 0x000000;
        this.Textbaozha.size = 30;
        this.Textbaozha.x = this.baozha.x - 7;
        this.Textbaozha.y = this.baozha.y - 14;
        this.baozha.touchEnabled = true;
        this.baozha.addEventListener(egret.TouchEvent.TOUCH_TAP, this.BaozhaClick, this);
        this.falsekou = new MImage("ball_png");
        this.addChild(this.falsekou);
        this.falsekou.anchorOffsetX = this.falsekou.width >> 1;
        this.falsekou.anchorOffsetY = this.falsekou.height >> 1;
        this.falsekou.x = 400; //400
        this.falsekou.y = 1000; //1050
        this.falsekou.scaleX = 0.5;
        this.falsekou.scaleY = 0.5;
        this.shangdan1();
        var world = new P2World(0, 200);
        var walls = world.createWall(new egret.Rectangle(0, 0, GameData.stageWidth, GameData.stageHeight));
        this.addChild(world);
        this.world = world;
        world.loopBackFun = this.loopP2World.bind(this);
        0;
        this.material = new p2.Material();
        //创建炮
        var gun = new Gun;
        gun.addEvent(EVENT_FIRE, this.onFire, this);
        this.addChild(gun);
        this.gun = gun;
        gun.x = this.getCenterX(1);
        gun.y = GameData.stageHeight - 180;
        //创建上方炮
        var guntop = new GunTop;
        guntop.addEvent(EVENT_FIRE, this.onFire, this);
        this.addChild(guntop);
        this.guntop = guntop;
        guntop.x = this.getCenterX(1);
        guntop.y = 130;
        //创建分享按钮 在舞台显示出来
        var xx = new shareButton;
        this.addChild(xx);
        this.Share = xx;
        this.Share.x = 60;
        this.Share.y = 1050;
        GameControl.GameControlSole = this;
        this.Share.touchEnabled = true;
        // var pos11;
        // // pos11.x=319;
        // // pos11.y=541;
        // //  this.startBackFun(pos11);
        /**线 */
        // this.shape1.graphics.lineStyle(3, 0xf8f8ff);
        // this.shape1
        // this.shape1.graphics.moveTo(this.gun.x, this.gun.y);
        // this.shape1.graphics.lineTo(this.gun.x, -100);
        // this.shape1.graphics.endFill();
        // this.gun.line.scaleX = this.gun.x;
        // this.gun.line.scaleY = this.gun.y;
        // this.addChild(this.shape1);
        //  this.setChildIndex(this.shape1, 1);
        //this.shape1.visible = false;
        // this.addChild(this.shape1);
        //创建子弹  
        /* this.MagnifyBullet = new py2Obj.magnifyBullet(this.world, this, this.removeSkins);
         this.MagnifyBullet.init();
         this.MagnifyBullet.setPostion(-300, -300);
         this.boomBullet = new py2Obj.BoomBullet(this.world, this, this.removeSkins);
         this.boomBullet.init();
         this.boomBullet.setPostion(-200, -200);
         // console.log(this.boomBullet.m_body);*/
        /**普通子弹 */
        this.fakeBullet = new py2Obj.fakeBullet(this.world, this, this.removeSkins);
        //  this.fakeBullet = new py2Obj.BoomBullet(this.world, this, this.removeSkins);
        this.fakeBullet.init();
        this.fakeBullet.setPostion(-100, -100);
        /**不可停下子弹 */
        this.Bulebullet = new py2Obj.BlueBullet(this.world, this, this.removeSkins);
        this.Bulebullet.init();
        this.Bulebullet.setPostion(-700, -700);
        /* this.gravityBullet = new py2Obj.gravityBullet(this.world, this, this.removeSkins);
         this.gravityBullet.init();
         this.gravityBullet.setPostion(-400, -400);
 
         this.strikeBullet = new py2Obj.strikeBullet(this.world, this, this.removeSkins);
         this.strikeBullet.init();
         this.strikeBullet.setPostion(-500, -500);*/
        this.NowBullet = this.fakeBullet;
        //创建碰撞显示
        var ce = new collideTime;
        this.addChild(ce);
        ce.x = -100;
        ce.y = -100;
        // this.NowBullet.addChild(ce);
        this.Collidetime = ce;
        //创建108固定显示
        var ww = new strikeTime;
        ww.x = -150;
        ww.y = -150;
        this.addChild(ww);
        this.Striketime = ww;
        //左上角分数的图片
        var img = new egret.Bitmap();
        img.texture = RES.getRes("zuoshangjiaofenshu_png");
        this.addChild(img);
        //this.addChildAt(img,410);
        this.setChildIndex(img, 30);
        this.doMaterial(this.fakeBullet.getBody());
        /**砖块 */
        this.zhuan = new py2Obj.zhuanWall(this.world, this, this.removeSkins);
        this.zhuan.init();
        this.zhuan.setPostion(this.getCenterX(0), 230);
        this.zhuanTop = new py2Obj.zhuanWall(this.world, this, this.removeSkins);
        this.zhuanTop.init();
        this.zhuanTop.setPostion(this.getCenterX(0), 850);
        this.zhuanTXT = new TextField();
        this.zhuanTopTXT = new TextField();
        this.zhuanTXT.text = this.zhuan.m_num.toString();
        this.zhuanTXT.x = this.getCenterX(0);
        this.zhuanTXT.y = 850;
        this.zhuanTopTXT.x = this.getCenterX(0);
        this.zhuanTopTXT.y = 230;
        this.zhuanTopTXT.text = this.zhuanTop.m_num.toString();
        this.addChild(this.zhuanTXT);
        this.addChild(this.zhuanTopTXT);
        //两个玩家
        this.playOne = new py2Obj.qiu(this.world, this, this.removeSkins);
        this.playOne.init();
        this.playOne.setPostion(this.getCenterX(0), 950);
        this.playOneHpTXT = new TextField();
        this.playOneHpTXT.x = 50;
        this.playOneHpTXT.y = 1080;
        this.playOneHpTXT.textColor = 0x00c4a851;
        this.playOneHpTXT.text = "剩余HP:" + this.playOneHp;
        this.addChild(this.playOneHpTXT);
        this.playTwoHpTXT = new TextField();
        this.playTwoHpTXT.x = 50;
        this.playTwoHpTXT.y = 20;
        this.playTwoHpTXT.textColor = 0x00c4a851;
        this.playTwoHpTXT.text = "剩余HP:" + this.playTwoHp;
        this.addChild(this.playTwoHpTXT);
        this.playTwo = new py2Obj.qiu(this.world, this, this.removeSkins);
        this.playTwo.init();
        this.playTwo.setPostion(this.getCenterX(0), 130);
        /**墙 */
        var TopWall = new py2Obj.bottomWall(this.world, this, this.removeSkins);
        TopWall.init();
        var DiWall = new py2Obj.bottomWall(this.world, this, this.removeSkins);
        DiWall.init();
        var liftWall = new py2Obj.basicWall(this.world, this, this.removeSkins);
        liftWall.init();
        var rightWall = new py2Obj.basicWall(this.world, this, this.removeSkins);
        rightWall.init();
        var pipeHight = liftWall.getBody().userData.skin.height / 2;
        var pipeY = this.setBottom(pipeHight, 100);
        liftWall.setPostion(-25, pipeY);
        rightWall.setPostion(this.getRight(-25), pipeY);
        TopWall.setPostion(this.getCenterX(0), -65);
        DiWall.setPostion(this.getCenterX(0), GameData.stageHeight + 65);
        //生成道具
        this.m_PropManager = new py2Obj.PropManager(this.world, this, this.removeSkins);
        // this.m_PropManager.createProp();//原来的
        this.m_PropManager.createPropXinShou(); //新手引导
        // this.m_PropManager.createProp(2);
        this.m_PropManager.m_props[0];
        this.m_PropManager.m_props1[0].setPostion(-1000, -100);
        //  this.createBottom();
        this.container = new Sprite;
        this.addChild(this.container);
        var conMask = moon.MoonUI.getRect(GameData.stageWidth, GameData.stageHeight - 200, 0, 0, 160);
        this.container.mask = conMask;
        var controlGun = new control.ControlBasic(this.stage);
        //controlGun.open();
        //this.Share.addEventListener(egret.TouchEvent.TOUCH_TAP,this.shareEvent,this);
        //  controlGun.clickShare = this.shareEvent.bind(this);//点击分享按钮（触发的事件）
        controlGun.startBackFun = this.startBackFun.bind(this); //摁下
        controlGun.moveBackFun = this.controlMove.bind(this); //移动
        controlGun.endBackFun = this.endBackFun.bind(this); //离开
        //controlGun.endBackFun = this.startBackFun.bind(this);//离开
        this.fashe.touchEnabled = true; //图片获取监听事件权限
        this.fashe.addEventListener(egret.TouchEvent.TOUCH_END, this.endBackFun1, this); //创建按钮监听事件bool
        this.fashe.addEventListener(egret.TouchEvent.TOUCH_END, this.endBackFun, this);
        this.Share.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.shareEvent, this);
        this.adjustment.addEventListener(egret.TouchEvent.TOUCH_TAP, this.qie, this);
        this.controlGun = controlGun;
        world.p2World.on("beginContact", this.onHitBegin.bind(this));
        world.p2World.defaultContactMaterial.restitution = 1; //反弹力
        //  world.p2World.on("impact",this.onHitImpact.bind(this));
        // world.p2World.on("postStep",this.onHitImpact.bind(this));
        this.txtScore = this.createText(50, 50);
        //this.txtScore.textColor=0;
        this.txtLevel = this.createText(200, -200);
        //this.initGame();
        //this.play();
        // this.updateNumBody();
        //this.testZero()
        this.bei = new MImage("bg_jpg");
        this.addChild(this.bei);
        this.addEventListener(egret.Event.ENTER_FRAME, this.huihe, this);
        this.addEventListener(egret.Event.ENTER_FRAME, this.timerFunc, this); //每帧执行方法
        this.addEventListener(egret.Event.ENTER_FRAME, this.bulletimg, this);
        this.addEventListener(egret.Event.ENTER_FRAME, this.updateHPTXT, this);
        //关闭不需要的组件
        this.chufa.visible = false;
        this.fangda.visible = false;
        this.baozha.visible = false;
        this.zhongli.visible = false;
        this.Textbaozha.visible = false;
        this.Textchufa.visible = false;
        this.Textfangda.visible = false;
        this.Textzhongli.visible = false;
        this.falsekou.visible = false;
        this.faan.visible = false;
        this.Share.visible = false;
        img.visible = false;
    };
    GameControl.prototype.updateHPTXT = function () {
        this.playOneHpTXT.text = "剩余HP:" + this.playOneHp;
        this.playTwoHpTXT.text = "剩余HP:" + this.playTwoHp;
        this.zhuanTXT.text = this.zhuan.m_num.toString();
        this.zhuanTopTXT.text = this.zhuanTop.m_num.toString();
        if (this.playOneHp == 0 || this.playTwoHp == 0) {
            this.over();
        }
        if (!this.qiehuan) {
            this.Collidetime.txtNum1.visible = true;
        }
        else {
            this.Collidetime.txtNum1.visible = false;
        }
    };
    GameControl.prototype.shengyin = function () {
        SoundControl.getIns().play(MUSIC_BG, 0, 9999);
    };
    GameControl.prototype.ChufaClick = function () {
        if (this.ChufaCount > 0) {
            this.ChufaCount -= 1;
            this.Textchufa.text = this.ChufaCount.toString();
            var pos1 = new egret.Point(this.my_chuchun[0].tu.x, this.my_chuchun[0].tu.y);
            this.changeColor2(0, pos1, 2);
            this.my_chuchun[0].objkind = 2; //触发子弹
        }
    };
    GameControl.prototype.BaozhaClick = function () {
        if (this.BaozhaCount > 0) {
            var pos1 = new egret.Point(this.my_chuchun[0].tu.x, this.my_chuchun[0].tu.y);
            this.BaozhaCount -= 1;
            this.Textbaozha.text = this.BaozhaCount.toString();
            this.changeColor2(0, pos1, 5);
            this.my_chuchun[0].objkind = 5; //爆炸子弹
        }
    };
    GameControl.prototype.FangdaClick = function () {
        if (this.FangdaCount > 0) {
            var pos1 = new egret.Point(this.my_chuchun[0].tu.x, this.my_chuchun[0].tu.y);
            this.FangdaCount -= 1;
            this.Textfangda.text = this.FangdaCount.toString();
            this.changeColor2(0, pos1, 3);
            this.my_chuchun[0].objkind = 3; //放大子弹
        }
    };
    GameControl.prototype.ZhongliClick = function () {
        if (this.ZhongliCount > 0) {
            var pos1 = new egret.Point(this.my_chuchun[0].tu.x, this.my_chuchun[0].tu.y);
            this.ZhongliCount -= 1;
            this.Textzhongli.text = this.ZhongliCount.toString();
            this.changeColor2(0, pos1, 4);
            this.my_chuchun[0].objkind = 4; //重力子弹
        }
    };
    /**分享事件 */
    GameControl.prototype.shareEvent = function () {
        if (this.fenxiang) {
            this.shareNum += 1;
            if (this.shareNum == 1) {
                var timer = new egret.Timer(500, 5);
                timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerComFunc1, this);
                timer.start();
            }
            platform.activeShare();
            platform.findShareQuery(this.shengyin);
        }
    };
    GameControl.prototype.timerComFunc1 = function () {
        this.gun.bullet += 1;
        this.gun.updateNum(this.gun.bullet);
    };
    /*public qie() {

        if (this.qiehuan) {
            this.faan.visible = true;
            this.addEvent(egret.Event.ADDED_TO_STAGE, this.controlMove, this);
            this.qiehuan = false;
            this.Weitiaojuli = 150;
            //新手指导
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁
            // this.adjustment.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            // this.bj.visible=false;
            // this.removeChild(this.bj);
            //this.upgradeNumber2 = 5;//新手引导
            //this.jixucishu+=1;

            //this.removeChild(this.btn);
        }
        else if (!this.qiehuan) {
            this.removeEventListener(egret.Event.ADDED, this.controlMove, this);
            this.faan.visible = false;
            this.qiehuan = true;
            this.Weitiaojuli = 0;
            this.Newarrow.visible = false;
            this.Newarrow1.visible = true;
            egret.Tween.get(this.Newarrow1, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁
            // this.addChild(this.bj);
            // this.bj.visible=true;
            // this.removeChild(this.bj);
            // // this.removeChild(this.btn);
            // if (this.upgradeNumber3 != 0) {
            //     this.upgradeNumber3 = 0;
            //     //this.upgradeNumber2=0;
            // }

        }

    }*/
    GameControl.prototype.huihe = function () {
        if (this.istop) {
            this.guntop.showLine();
            this.gun.hideLine();
            this.xiaoluntop.visible = true;
            this.xiaofaan.visible = false;
            this.playTwo.m_body.collisionResponse = false;
            this.playOne.m_body.collisionResponse = true;
            this.playTwo.objkind = 10000;
            this.playOne.objkind = 500;
            this.zhuanTop.setPostion(-600, -600);
            if (this.zhuan.m_num > 0) {
                this.zhuanTXT.visible = true;
                this.zhuan.setPostion(this.getCenterX(0), 850);
            }
            else {
                this.zhuanTXT.visible = false;
            }
            this.zhuanTopTXT.visible = false;
            this.zhuanTop.objkind = 10000;
            this.zhuan.objkind = 600;
        }
        else if (!this.istop) {
            this.gun.showLine();
            this.guntop.hideLine();
            this.xiaoluntop.visible = false;
            this.xiaofaan.visible = true;
            this.playOne.m_body.collisionResponse = false;
            this.playTwo.m_body.collisionResponse = true;
            this.playOne.objkind = 10000;
            this.playTwo.objkind = 500;
            this.zhuan.setPostion(-600, -600);
            if (this.zhuanTop.m_num > 0) {
                this.zhuanTop.setPostion(this.getCenterX(0), 230);
                this.zhuanTopTXT.visible = true;
            }
            else {
                this.zhuanTopTXT.visible = false;
            }
            this.zhuanTXT.visible = false;
            this.zhuan.objkind = 10000;
            this.zhuanTop.objkind = 600;
        }
    };
    GameControl.prototype.qie = function () {
        if (!this.qiehuan) {
            this.qiehuan = true;
            this.Collidetime.txtNum1.visible = false;
        }
        else {
            this.qiehuan = false;
            this.Collidetime.txtNum1.visible = true;
        }
    };
    GameControl.prototype.bulletimg = function () {
        if (this.qiehuan) {
            this.nowBulletImgBule.visible = true;
            this.nowBulletImg.visible = false;
        }
        else {
            this.nowBulletImgBule.visible = false;
            this.nowBulletImg.visible = true;
        }
    };
    //碰撞次数显示位置
    GameControl.prototype.timerFunc = function () {
        // if (!this.yinxiaoBool) {
        //     SoundControl.getIns().play(MUSIC_BG, 0, 9999);
        //     this.yinxiaoBool = true;
        // }
        if (this.faguang) {
            var color = 0x33CCFF; /// 光晕的颜色，十六进制，不包含透明度
            var alpha = 0.8; /// 光晕的颜色透明度，是对 color 参数的透明度设定。有效值为 0.0 到 1.0。例如，0.8 设置透明度值为 80%。
            var blurX = 0; /// 水平模糊量。有效值为 0 到 255.0（浮点）
            var blurY = 0; /// 垂直模糊量。有效值为 0 到 255.0（浮点）
            var strength = 5; /// 压印的强度，值越大，压印的颜色越深，而且发光与背景之间的对比度也越强。有效值为 0 到 255。暂未实现
            var quality = 3 /* HIGH */; /// 应用滤镜的次数，建议用 BitmapFilterQuality 类的常量来体现
            var inner = false; /// 指定发光是否为内侧发光，暂未实现
            var knockout = false; /// 指定对象是否具有挖空效果，暂未实现
            var glowFilter = new egret.GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout);
            this.glowFilter = glowFilter;
            this.gun.line.filters = [this.glowFilter];
        }
        else {
            this.gun.line.filters = [];
        }
        // if (this.my_chuchun.length > 0) {
        //     if (this.NowBullet.isRun == false && this.boomNum >= 4 && this.my_chuchun[0].objkind == 1)//判断第五发是爆炸球
        //     {
        //         this.sffaqiu = true;
        //         this.removeChild(this.my_chuchun[0].tu)
        //         var tu = new MImage(lizitexiao[5]);
        //         this.addChild(tu);
        //         tu.anchorOffsetX = tu.height >> 1;
        //         tu.anchorOffsetY = tu.width >> 1;
        //         tu.x = 319;
        //         tu.y = 887;
        //         egret.Tween.get(tu).to({ scaleX: 2, scaleY: 2 }, 500).call(() => {
        //             this.removeChild(tu)
        //             this.my_chuchun[0].objkind = 5;
        //             var pos2 = new egret.Point(319, 887)
        //             this.changeColor2(0, pos2, 5)
        //             this.sffaqiu = false;
        //         })
        //         egret.Tween.get(tu).to({ alpha: 0 }, 500)
        //         this.boomNum = 0;
        //     }
        // }
        //判断发射球的半径
        if (this.NowBullet.isRun == false && this.shu11 == 0) {
            if (this.my_chuchun.length != 0) {
                if (this.my_chuchun[0].objkind == 3) {
                    this.e = 45;
                }
                else {
                    this.e = 13;
                }
            }
            else {
                this.e = 13;
            }
            this.shu11 = 1;
            if (this.fashezhuo == null) {
                var pos;
                pos = { x: this.gun.x, y: this.gun.y - 100 };
                this.fashezhuo = pos;
                this.startBackFun(pos);
            }
            else {
                this.startBackFun(this.fashezhuo);
            }
            Tween.get(this.faan).to({ alpha: 1 }, 200);
        }
        if (this.NowBullet.isRun == true) {
            this.Collidetime.x = this.NowBullet.m_body.position[0] - 5;
            this.Collidetime.y = this.NowBullet.m_body.position[1] - 5;
        }
        if (this.NowBullet.m_body.position[0] < 0 || this.NowBullet.m_body.position[0] > 634 || this.NowBullet.m_body.position[1] < 0 || this.NowBullet.m_body.position[1] > 1691) {
            this.NowBullet.isRun = false;
        }
        // if (this.gun.bullet <= 0 && this.NowBullet.isRun == false) {
        //     this.isOver = 1;
        //     this.over();
        //     //this.NowBullet.isRun=true;
        // }
        if (this.overValue == 0) {
            for (var i = 0; i < this.my_strikeBall.length; i++) {
                if (this.my_strikeBall[i].objkind == 108) {
                    this.Striketime.x = this.my_strikeBall[i].m_body.position[0] - 5;
                    this.Striketime.y = this.my_strikeBall[i].m_body.position[1] - 5;
                    this.Striketime.updateNum(this.Striketime.chufashuzi);
                    this.addChild(this.Striketime);
                }
            }
        }
    };
    GameControl.prototype.timerComFunc = function () {
    };
    GameControl.prototype.initView = function () {
        //需要复写
    };
    GameControl.prototype.initGame = function () {
        this.score = 0;
        //  this.level = 0;
        this.ballNum = 0;
        this.moveNum = 0;
        this.gun.restart();
        this.guntop.restart();
        //this.updateScore();
        this.controlGun.open();
        this.playOneHp = 5;
        this.playTwoHp = 5;
        this.chushihua();
    };
    GameControl.prototype.chushihua = function () {
        this.zhuan.setPostion(this.getCenterX(0), 230);
        this.zhuan.m_num = 5;
        this.zhuanTop.m_num = 5;
        this.zhuanTop.setPostion(this.getCenterX(0), 850);
        this.huiheNum = 0;
    };
    /**复活 */
    GameControl.prototype.revive = function () {
        this.moveNum = 0;
        this.ballNum = 0;
        this.play();
        this.controlGun.open();
    };
    GameControl.prototype.setBottom = function (height, distance) {
        return GameData.stageHeight - height - distance;
    };
    GameControl.prototype.moveNumBody = function () {
        var bodys = this.world.p2World.bodies;
        var l = bodys.length;
        for (var i = 0; i < l; i++) {
            var body = bodys[i];
            if (body.userData && body.userData.skin) {
                if (body.userData["num"]) {
                    body.position[1] -= 10;
                    if (body.position[1] <= OVER_DIS) {
                        if (body.userData.skin.imageName != ICON_ADD) {
                            this.over();
                            return;
                        }
                    }
                }
            }
        }
        if (this.moveNum < 7) {
            this.moveNum++;
            setTimeout(this.moveNumBody.bind(this), 50);
        }
        else {
            this.moveNum = 0;
            this.controlGun.open();
        }
    };
    /**结束 */
    GameControl.prototype.over = function () {
        _super.prototype.over.call(this);
        this.controlGun.close();
        var bodys = this.world.p2World.bodies;
        this.empty();
        /**新手指导 */
        this.empty1(); //如果场景里存在金币，清除金币
        this.count = 0;
        this.upgradeNumber = 1;
        this.shareNum = 0;
        this.gun.gun.rotation = 180;
        this.gun.ball.rotation = 180;
        this.BaozhaCount = 0;
        this.ChufaCount = 0;
        this.ZhongliCount = 0;
        this.FangdaCount = 0;
        this.Textchufa.text = this.ChufaCount.toString();
        this.Textbaozha.text = this.BaozhaCount.toString();
        this.Textzhongli.text = this.ZhongliCount.toString();
        this.Textfangda.text = this.FangdaCount.toString();
        // this.NowBullet1 = this.fakeBullet;
        // this.changeColor1();
        this.sffaqiu = false;
        this.shangdan1();
        this.my_ball = [];
        this.boomNum = 0;
        this.m_PropManager.allProps = [];
        this.isOver = 0;
        this.upgradeNumber = 1;
        if (this.m_PropManager.m_props1.length == 0) {
            //  this.m_PropManager.createProp();//原来的
            this.m_PropManager.createPropXinShou(); //新手引导
        }
        // this.removeFromParent(this.Striketime);
        // if (this.Striketime != null) {
        this.my_strikeBall = [];
        this.Striketime.chufashuzi = 3;
        this.Striketime.x = -100;
        this.Striketime.y = -100;
        this.Collidetime.x = -150;
        this.Collidetime.y = -150;
        this.overValue = 1;
        // this.addChild(this.Striketime);
        //this.removeChild(this.Striketime);
        //  }
        this.sendMsg(GameData.score);
        // console.log(GameData.score);
        // this.my_ball.push(this.m_PropManager.m_props[0]);
        // this.m_PropManager=null;
        // this.m_PropManager = new py2Obj.PropManager(this.world, this, this.removeSkins);
        // this.m_PropManager.createProp(1);
        // this.m_PropManager.m_prop/**/s[0];
    };
    /*调取开放域*/
    GameControl.prototype.sendMsg = function (n) {
        // let platform: any = window.platform;
        // platform.openDataContext.postMessage({
        //     score: n.toString()
        // });
    };
    GameControl.prototype.empty = function () {
        var bodys = this.world.p2World.bodies;
        for (var i = 0; i < bodys.length; i++) {
            var body = bodys[i];
            if (body.userData && body.userData.skin) {
                if (body.userData.data.objkind == 100 || body.userData.data.objkind == 108 /*||body.userData.data.objkind == 400||body.userData.data.objkind == 401*/) {
                    var skin = body.userData.skin;
                    this.world.removeBodys.push(body);
                    skin.removeFromParent(true);
                }
            }
        }
    };
    /** */
    GameControl.prototype.empty1 = function () {
        var bodys = this.world.p2World.bodies;
        for (var i = 0; i < bodys.length; i++) {
            var body = bodys[i];
            if (body.userData && body.userData.skin) {
                if (body.userData.data.objkind == 400) {
                    var skin = body.userData.skin;
                    this.world.removeBodys.push(body);
                    skin.removeFromParent(true);
                }
            }
        }
    };
    GameControl.prototype.updateNumBody = function () {
        return;
    };
    /**帧动画 */
    GameControl.prototype.frameAnimation = function (X, y) {
        var _this = this;
        var texture2mc = RES.getRes("Boom_png");
        var data2mc = RES.getRes("Boom_json");
        var mcFactory = new egret.MovieClipDataFactory(data2mc, texture2mc);
        var mc = new egret.MovieClip(mcFactory.generateMovieClipData("Boom"));
        this.addChild(mc);
        mc.gotoAndPlay("Boom", 1); //"A" : Boom -1 ： 循环播放				
        mc.x = X - 60;
        mc.y = y - 60;
        mc.addEventListener(egret.Event.COMPLETE, function (e) {
            _this.removeChild(mc);
        }, this);
        this.Collidetime.x = -55;
        this.Collidetime.y = -55;
    };
    GameControl.prototype.shangdan1 = function () {
        if (this.my_chuchun.length < 1) {
            var a = new chun;
            a.tu = new MImage("ball_png");
            a.objkind = 1;
            a.tu.anchorOffsetX = a.tu.width / 2;
            a.tu.anchorOffsetY = a.tu.height / 2;
            a.tu.x = 319; //264
            a.tu.y = 10000; //922
            this.addChild(a.tu);
            this.my_chuchun.push(a);
            // this.shangdan();
        }
    };
    /**确定 */
    GameControl.prototype.que = function (a, b) {
        var c = 3;
        if (a == 887) {
            c = 0;
        }
        if (a == 1000) {
            c = 1;
        }
        if (a == 1000 && b == 320) {
            c = 2;
        }
        return c;
    };
    /**上子弹 */
    // private shangdan() {
    //     //改变子弹运行轨迹
    //     if (this.my_chuchun.length > 0) {
    //         if (this.my_chuchun[0].tu.x == 320) {
    //             egret.Tween.get(this.my_chuchun[0].tu).to({ x: 240, y: 1000 }, 200).to({ x: 319, y: 887 }, 200)
    //         }
    //         else if (this.my_chuchun[0].tu.x == 240 || this.my_chuchun[0].tu.x == 319) {
    //             egret.Tween.get(this.my_chuchun[0].tu).to({ x: 319, y: 887 }, 200)
    //         }
    //         else {
    //             egret.Tween.get(this.my_chuchun[0].tu).to({ x: 320, y: 1000 }, 200).to({ x: 240, y: 1000 }, 200).to({ x: 319, y: 887 }, 200)
    //         }
    //         if (this.my_chuchun.length >= 2) {
    //             if (this.my_chuchun[1].tu.x == 320 || this.my_chuchun[1].tu.x == 240) {
    //                 egret.Tween.get(this.my_chuchun[1].tu).to({ x: 240, y: 1000 }, 200)
    //             }
    //             else {
    //                 egret.Tween.get(this.my_chuchun[1].tu).to({ x: 320, y: 1000 }, 200).to({ x: 240, y: 1000 }, 200)
    //             }
    //         } if (this.my_chuchun.length >= 3) {
    //             egret.Tween.get(this.my_chuchun[2].tu).to({ x: 320, y: 1000 }, 200)
    //         }
    //     }
    // }
    /**其他吃到道具金币粒子特效 */
    GameControl.prototype.liziy = function (zhu, shu, shu2) {
        var _this = this;
        this.sffaqiu = true;
        if (zhu.x > 0 && this.gun.bullet > 0 || zhu.x > 0 && this.gun.bullet <= 0 && shu == 1) {
            var pos = new egret.Point(0, 0);
            var shudu = 0;
            if (shu == 0) {
                SoundControl.getIns().addItem(MUSIC_Jinbi);
                SoundControl.getIns().play(MUSIC_Jinbi);
                pos = new egret.Point(45, 33);
                // shudu = Math.sqrt(Math.pow(zhu.x - 45, 2) + Math.pow(zhu.y - 40, 2))
            }
            else if (shu == 1) {
                console.log(this.jiaQiuCount);
                SoundControl.getIns().addItem(MUSIC_Eatdaoju);
                SoundControl.getIns().play(MUSIC_Eatdaoju);
                if (this.upgradeNumber == 1) {
                    shudu = Math.sqrt(Math.pow(zhu.x - 274, 2) + Math.pow(zhu.y - 1094, 2));
                    pos = new egret.Point(274, 1094);
                }
                else {
                    if (this.jiaQiuCount > 0) {
                        shudu = Math.sqrt(Math.pow(zhu.x - 274, 2) + Math.pow(zhu.y - 1094, 2));
                        pos = new egret.Point(274, 1094);
                    }
                }
            }
            else if (shu == 2) {
                SoundControl.getIns().addItem(MUSIC_Eatdaoju);
                SoundControl.getIns().play(MUSIC_Eatdaoju);
                shudu = Math.sqrt(Math.pow(zhu.x - 210, 2) + Math.pow(zhu.y - 1010, 2));
                pos = new egret.Point(210, 1010);
                // for (let i = 0; i < this.my_chuchun.length; ++i) {
                //     if (this.my_chuchun[i].objkind == 1) {
                //         pos = new egret.Point(this.my_chuchun[i].tu.x, this.my_chuchun[i].tu.y);
                //         this.my_chuchun[i].objkind = shu;
                //         break;
                //     }
                // }
                /** 箭头指示*/
                this.Newjiantou.visible = false;
            }
            else if (shu == 3) {
                SoundControl.getIns().addItem(MUSIC_Eatdaoju);
                SoundControl.getIns().play(MUSIC_Eatdaoju);
                shudu = Math.sqrt(Math.pow(zhu.x - 280, 2) + Math.pow(zhu.y - 1010, 2));
                pos = new egret.Point(280, 1010);
                /** 新手指导箭头指示*/
                this.Newjiantou.visible = false;
            }
            else if (shu == 4) {
                SoundControl.getIns().addItem(MUSIC_Eatdaoju);
                SoundControl.getIns().play(MUSIC_Eatdaoju);
                shudu = Math.sqrt(Math.pow(zhu.x - 350, 2) + Math.pow(zhu.y - 1010, 2));
                pos = new egret.Point(350, 1010);
                /** 新手指导箭头指示*/
                this.Newjiantou.visible = false;
            }
            else if (shu == 5) {
                SoundControl.getIns().addItem(MUSIC_Eatdaoju);
                SoundControl.getIns().play(MUSIC_Eatdaoju);
                shudu = Math.sqrt(Math.pow(zhu.x - 420, 2) + Math.pow(zhu.y - 1010, 2));
                pos = new egret.Point(420, 1010);
                /** 箭头指示*/
                this.Newjiantou.visible = false;
            }
            var texture = RES.getRes(lizitexiao[shu]); //粒子特效
            var config = RES.getRes("FangdaQiu_json");
            var particleSys = new particle.GravityParticleSystem(texture, config);
            particleSys.emitterX = zhu.x;
            particleSys.emitterY = zhu.y;
            this.addChild(particleSys);
            particleSys.start(shudu / 0.7);
            egret.Tween.get(particleSys).to({ emitterX: pos.x, emitterY: pos.y }, shudu / 0.7).call(function () {
                if (particleSys.emitterX == 210 && particleSys.emitterY == 1010) {
                    // this.my_chuchun2.push(shu);
                    _this.ChufaCount++;
                    _this.Textchufa.text = _this.ChufaCount.toString();
                    _this.upgradeNumber2 = 53; //新手引导
                    _this.UpgradeTishi();
                }
                if (particleSys.emitterX == 280 && particleSys.emitterY == 1010) {
                    _this.FangdaCount++;
                    _this.Textfangda.text = _this.FangdaCount.toString();
                    _this.upgradeNumber2 = 52; //
                    _this.UpgradeTishi();
                }
                if (particleSys.emitterX == 350 && particleSys.emitterY == 1010) {
                    _this.ZhongliCount++;
                    _this.Textzhongli.text = _this.ZhongliCount.toString();
                    _this.upgradeNumber2 = 54; //新手引导
                    _this.UpgradeTishi();
                }
                if (particleSys.emitterX == 420 && particleSys.emitterY == 1010) {
                    _this.BaozhaCount++;
                    _this.Textbaozha.text = _this.BaozhaCount.toString();
                    _this.upgradeNumber2 = 51; //新手引导
                    _this.UpgradeTishi();
                }
                var tu = new MImage(lizitexiao[shu]);
                _this.addChild(tu);
                tu.anchorOffsetX = tu.height >> 1;
                tu.anchorOffsetY = tu.width >> 1;
                tu.x = particleSys.emitterX;
                tu.y = particleSys.emitterY;
                egret.Tween.get(tu).to({ scaleX: 2, scaleY: 2 }, 500).call(function () { _this.removeChild(tu); });
                egret.Tween.get(tu).to({ alpha: 0 }, 500);
                var time1 = new egret.Timer(150, 1);
                time1.start();
                time1.addEventListener(egret.TimerEvent.TIMER, function (eve) {
                    _this.sffaqiu = false;
                    var que = _this.que(tu.y, tu.x);
                    if (shu != 0 && shu != 1 && que != 3) {
                        var pos1 = new egret.Point(_this.my_chuchun[que].tu.x, _this.my_chuchun[que].tu.y);
                        _this.removeChild(_this.my_chuchun[que].tu);
                        _this.changeColor2(que, pos1, shu);
                    }
                    if (shu == 0) {
                        _this.count += 1;
                        _this.upgradeNumber2 = 3; //新手引导
                        _this.UpgradeTishi();
                        _this.score = _this.count;
                        _this.updateScore();
                        if (_this.count >= 20 && _this.upgradeNumber == 1) {
                            _this.Upgrade();
                            _this.upgradeNumber += 1;
                        }
                        else if (_this.count >= 50 && _this.upgradeNumber == 2) {
                            _this.Upgrade();
                            _this.upgradeNumber += 1;
                        }
                        else if (_this.count >= 80 && _this.upgradeNumber == 3) {
                            _this.Upgrade();
                            _this.upgradeNumber += 1;
                        }
                    }
                    else if (shu == 1) {
                        if (_this.upgradeNumber == 1) {
                            _this.gun.updateNum(++(_this.gun.bullet));
                        }
                        else {
                            if (_this.jiaQiuCount > 0) {
                                _this.gun.updateNum(++(_this.gun.bullet));
                            }
                        }
                    }
                }, _this);
            });
            if (shu2 != 0) {
                var time = new egret.Timer(400, shu2);
                time.start();
                time.addEventListener(egret.TimerEvent.TIMER, function (eve) {
                    var texture = RES.getRes(lizitexiao[shu]); //粒子特效
                    var config = RES.getRes("FangdaQiu_json");
                    var particleSys = new particle.GravityParticleSystem(texture, config);
                    particleSys.emitterX = zhu.x;
                    particleSys.emitterY = zhu.y;
                    _this.addChild(particleSys);
                    particleSys.start(shudu / 0.7);
                    egret.Tween.get(particleSys).to({ emitterX: pos.x, emitterY: pos.y }, shudu / 0.7).call(function () {
                        if (pos.x == 210 && pos.y == 1010) {
                            _this.ChufaCount++;
                            _this.Textchufa.text = _this.ChufaCount.toString();
                            //  this.my_chuchun2.push(shu);
                        }
                        if (pos.x == 280 && pos.y == 1010) {
                            _this.FangdaCount++;
                            _this.Textfangda.text = _this.FangdaCount.toString();
                        }
                        if (pos.x == 350 && pos.y == 1010) {
                            _this.ZhongliCount++;
                            _this.Textzhongli.text = _this.ZhongliCount.toString();
                        }
                        if (pos.x == 420 && pos.y == 1010) {
                            _this.BaozhaCount++;
                            _this.Textbaozha.text = _this.BaozhaCount.toString();
                        }
                        var tu = new MImage(lizitexiao[shu]);
                        _this.addChild(tu);
                        tu.anchorOffsetX = tu.height >> 1;
                        tu.anchorOffsetY = tu.width >> 1;
                        tu.x = particleSys.emitterX;
                        tu.y = particleSys.emitterY;
                        egret.Tween.get(tu).to({ scaleX: 2, scaleY: 2 }, 500).call(function () { _this.removeChild(tu); });
                        egret.Tween.get(tu).to({ alpha: 0 }, 500);
                        var time2 = new egret.Timer(150, 1);
                        time2.start();
                        time2.addEventListener(egret.TimerEvent.TIMER, function (eve) {
                            _this.sffaqiu = false;
                            var que = _this.que(tu.y, tu.x);
                            if (shu != 0 && shu != 1 && que != 3) {
                                var pos1 = new egret.Point(_this.my_chuchun[que].tu.x, _this.my_chuchun[que].tu.y);
                                _this.removeChild(_this.my_chuchun[que].tu);
                                console.log("--------++++++++++--------------" + que);
                                _this.changeColor2(que, pos1, shu);
                            }
                            if (shu == 0) {
                                _this.count += 1;
                                _this.score = _this.count;
                                _this.updateScore();
                            }
                            else if (shu == 1) {
                                if (_this.upgradeNumber == 1) {
                                    _this.gun.updateNum(++(_this.gun.bullet)); //4444444444
                                }
                                else {
                                    if (_this.jiaQiuCount > 0) {
                                        _this.gun.updateNum(++(_this.gun.bullet)); //4444444444
                                    }
                                }
                            }
                        }, _this);
                    });
                    //  egret.Tween.get(particleSys).to({x:320,y:880},2000)
                }, this);
            }
        }
    };
    /**改变子弹颜色 */
    GameControl.prototype.changeColor2 = function (a, zhu, shu) {
        this.my_chuchun[a].tu = new MImage(lizitexiao[shu]);
        this.addChild(this.my_chuchun[a].tu);
        this.my_chuchun[a].tu.anchorOffsetX = this.my_chuchun[a].tu.width / 2;
        this.my_chuchun[a].tu.anchorOffsetY = this.my_chuchun[a].tu.height / 2;
        this.my_chuchun[a].tu.x = zhu.x;
        this.my_chuchun[a].tu.y = zhu.y;
    };
    /**关卡界面*/
    GameControl.prototype.Upgrade = function () {
        /**新手指导 */
        // if (tishi != 5) {
        //     tishi += 1;
        //     this.upgradeNumber2 += 1;
        // }
        // else if (tishi == 5) {
        //     return;
        // }
        var bj = new MImage("startPanel1_png");
        this.bj = bj;
        var btn = new MButton(new MImage("btnStart_png"), new MImage("btnStart_png"));
        this.btn = btn;
        this.addChild(this.bj);
        this.addChild(this.btn);
        btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
        btn.x = (this.stageWidth - btn.width) >> 1;
        btn.y = 650;
        var upgradeText = new egret.TextField();
        upgradeText.width = 400;
        upgradeText.height = 400;
        upgradeText.x = 140;
        upgradeText.y = 400;
        upgradeText.textColor = 0x00c4a851;
        upgradeText.size = 30;
        upgradeText.textAlign = egret.HorizontalAlign.CENTER;
        //  upgradeText.verticalAlign = egret.VerticalAlign.MIDDLE;
        if (this.upgradeNumber == 1) {
            upgradeText.text = "难度增加\n\n直接撞击金币不加子弹，经过反弹后打到金币才加子弹";
        }
        else if (this.upgradeNumber == 2) {
            upgradeText.text = "难度增加\n\n道具出现概率降低";
        }
        else if (this.upgradeNumber == 3) {
            upgradeText.text = "星空中随机出现金币数量增加";
        }
        else if (this.upgradeNumber == 4) {
            upgradeText.text = "难度增加\n\n星空中随机出现金币，打不到消失";
        }
        bj.addChild(upgradeText);
    };
    GameControl.prototype.UpgradeTishi = function () {
        // var xinbool=egret.localStorage.getItem("xinshouyindao");
        // if(xinbool=="false")   
        // console.log("啦啦啦啦啦啦" + egret.localStorage.getItem("xinshouyindao"));
        // if (egret.localStorage.getItem("xinshouyindao") == "false") {
        /**新手指导 */
        if (tishi != 9) {
            tishi += 1;
            // this.upgradeNumber2 += 1;//新手引导
        }
        else if (tishi == 9) {
            return;
        }
        var bj = new MImage("startPanel1_png");
        this.bj = bj;
        var btn = new MButton(new MImage("jixu_png"), new MImage("jixu_png"));
        this.btn = btn;
        btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
        btn.x = (this.stageWidth - btn.width) >> 1;
        btn.y = 650;
        var upgradeText = new egret.TextField();
        upgradeText.width = 400;
        upgradeText.height = 400;
        upgradeText.x = 140;
        upgradeText.y = 400;
        upgradeText.textColor = 0x00c4a851;
        upgradeText.size = 32;
        upgradeText.textAlign = egret.HorizontalAlign.CENTER;
        var text3 = new egret.TextField();
        text3.text = "点击发射按钮或空白处继续";
        text3.textColor = 0x00c4a851;
        text3.size = 32;
        text3.width = 1000;
        text3.x = 140;
        text3.y = 700;
        if (this.upgradeNumber2 == 100 && this.upgradeNumber3 == 0) {
            var bj = new MImage("startPanel1_png");
            this.bj = bj;
            var btn = new MButton(new MImage("jixu_png"), new MImage("jixu_png"));
            this.btn = btn;
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            btn.x = (this.stageWidth - btn.width) >> 1;
            btn.y = 650;
            var upgradeText = new egret.TextField();
            upgradeText.width = 400;
            upgradeText.height = 400;
            upgradeText.x = 140;
            upgradeText.y = 400;
            upgradeText.textColor = 0x00c4a851;
            upgradeText.size = 32;
            upgradeText.textAlign = egret.HorizontalAlign.CENTER;
            this.upgradeNumber3 = 1; //防止弹出界面同时出现
            tanChuang = 1;
            upgradeText.text = "点击发射按钮";
            bj.addChild(upgradeText);
            this.addChild(this.bj);
            this.addChild(this.fashe); //新手引导
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            // egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
            // this.addChild(this.Newarrow);
            //egret.Tween.get(this.Newarrow,{loop:true}).to({ alpha: 0}, 200).to({ alpha: 1}, 200); //颜色闪烁    
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        }
        else if (this.upgradeNumber2 == 2 && this.upgradeNumber3 == 0) {
            this.upgradeNumber3 = 2;
            tanChuang = 1;
            this.upgradeNumber4 = 2;
            // bj.addChild(text3)
            upgradeText.text = "短时间内再次点击空白处或发射按钮子弹静止";
            bj.addChild(upgradeText);
            this.addChild(this.bj);
            this.addChild(this.fashe);
            /**新手指导 */
            // this.addChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            //  this.addChild(this.Newarrow);
            // Tween.get(this.Newarrow).to({alpha:0},1000);  
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁    
            // egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        }
        else if (this.upgradeNumber2 == 3 && this.upgradeNumber3 == 0 && this.jinbicishu == 0) {
            this.upgradeNumber3 = 3;
            tanChuang = 1;
            this.upgradeNumber4 = 1;
            this.jinbicishu = 3;
            bj.addChild(text3);
            upgradeText.text = "上方分数加1，\n下方子弹补充1\n每经过一次反弹，\n分数和子弹会再加1";
            var text = new egret.TextField();
            text.text = "分数加1";
            text.textColor = 0x00ff00;
            text.size = 50;
            text.width = 400;
            text.x = 240 - text.textWidth / 2;
            text.y = 40 - text.textHeight / 2;
            var text2 = new egret.TextField();
            text2.text = "子弹数加1";
            text2.textColor = 0x00ff00;
            text2.size = 50;
            text2.width = 400;
            text2.x = 350;
            text2.y = 1055;
            bj.addChild(text);
            bj.addChild(text2);
            bj.addChild(upgradeText);
            //this.bj.visible=true;
            this.addChild(this.bj);
            this.addChild(this.fashe);
            /**新手指导 */
            // this.addChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            //this.addChild(this.Newarrow);
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁    
            /**新手指导的箭头指示 */
            this.Newjiantou.visible = false;
            // egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
            //Tween.get(this.Newarrow).to({alpha:1},800);           
        }
        else if (this.upgradeNumber2 == 4 && this.upgradeNumber3 == 0) {
            this.upgradeNumber3 = 4;
            tanChuang = 1;
            this.upgradeNumber4 = 1;
            // bj.addChild(text3)
            upgradeText.text = "右下方第二个按钮为微调大轮盘（微调作用）的显示与隐藏即微调按钮，默认开启";
            bj.addChild(upgradeText);
            //  bj.addChild(text3);
            this.addChild(this.bj);
            // this.addChild(this.btn);
            this.addChild(this.fashe);
            this.Newarrow.visible = false;
            this.Newarrow1.visible = true;
            //this.addChild(this.Newarrow);
            egret.Tween.get(this.Newarrow1, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁    
        }
        else if (this.upgradeNumber2 == 51 && this.upgradeNumber3 == 0) {
            this.upgradeNumber3 = 5;
            tanChuang = 1;
            this.upgradeNumber4 = 1; //
            bj.addChild(text3);
            upgradeText.text = "爆炸道具：效果为：打出后点击第二次可以把自己附近的基础球炸掉。每经过一次反弹，得到的道具数量会加1";
            bj.addChild(upgradeText);
            this.addChild(this.bj);
            this.addChild(this.fashe);
            /**新手指导 */
            // this.addChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁    
            // egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        }
        else if (this.upgradeNumber2 == 52 && this.upgradeNumber3 == 0) {
            this.upgradeNumber3 = 5;
            tanChuang = 1;
            this.upgradeNumber4 = 1; //新手引导
            bj.addChild(text3);
            upgradeText.text = "放大道具：效果为：打出后的子弹很大。每经过一次反弹，得到的道具数量会加1";
            bj.addChild(upgradeText);
            this.addChild(this.bj);
            this.addChild(this.fashe);
            /**新手指导 */
            // this.addChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁    
            // egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        }
        else if (this.upgradeNumber2 == 53 && this.upgradeNumber3 == 0) {
            this.upgradeNumber3 = 5;
            tanChuang = 1;
            this.upgradeNumber4 = 1; //新手引导
            bj.addChild(text3);
            var daojuText = new egret.TextField();
            daojuText.width = 400;
            daojuText.height = 400;
            daojuText.x = 140;
            daojuText.y = 330;
            daojuText.textColor = 0x00c4a851;
            daojuText.size = 32;
            daojuText.textAlign = egret.HorizontalAlign.CENTER;
            daojuText.text = "触发道具：打出子弹后点击第二次可以停留在舞台成为触发球。效果为：打出的子弹如果从触发球内穿过然后碰到基础球可以把基础球消掉并且触发球触发次数减1，触发球可触发次数为3，触发次数为0时，触发球消失。每经过一次反弹，得到的道具数量会加1";
            bj.addChild(daojuText);
            this.addChild(this.bj);
            this.addChild(this.fashe);
            /**新手指导 */
            // this.addChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁   
        }
        else if (this.upgradeNumber2 == 54 && this.upgradeNumber3 == 0) {
            this.upgradeNumber3 = 5;
            tanChuang = 1;
            this.daojutishi = 1;
            this.upgradeNumber4 = 1; //新手引导
            bj.addChild(text3);
            upgradeText.text = "重力道具：效果为：打出子弹后点击第二次子弹会垂直下落，途中如果碰到基础球可以把基础球消失。每经过一次反弹，得到的道具数量会加1";
            bj.addChild(upgradeText);
            this.addChild(this.bj);
            this.addChild(this.fashe);
            /**新手指导 */
            // this.addChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            this.Newarrow.visible = true;
            this.Newarrow1.visible = false;
            egret.Tween.get(this.Newarrow, { loop: true }).to({ alpha: 0 }, 200).to({ alpha: 1 }, 200); //颜色闪烁    
        }
        else if (this.upgradeNumber2 == 6 && this.upgradeNumber3 == 0) {
            this.upgradeNumber3 = 6;
            tanChuang = 1;
            // var btnStart: MButton = new MButton(new MImage("btnStart_png"), new MImage("btnStart_png"));
            // this.controlGun.close();
            // btnStart.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClick, this);
            // btnStart.x = (this.stageWidth - btnStart.width) >> 1;
            // btnStart.y = 650;
            var bj2 = new MImage("over2Panel_png");
            this.bj = bj2;
            var btn = new MButton(new MImage("btnStart_png"), new MImage("btnStart_png"));
            this.btn = btn;
            btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.zhengshiStart, this);
            btn.x = (this.stageWidth - btn.width) >> 1;
            btn.y = 650;
            this.addChild(this.bj);
            this.addChild(btn);
            /**新手指导 */
            // this.removeChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            // this.Newarrow.visible = false;
            // this.Newarrow1.visible = false;
            this.removeChild(this.Newarrow);
            this.removeChild(this.Newarrow1);
            /**新手指导结束 */
            //     egret.localStorage.setItem("xinshouyindao", "true");
            //     console.log("反馈技术附件该接口" + egret.localStorage.getItem("xinshouyindao"));
            // }
        }
        else {
            // this.removeChild(this.Newarrow);
            // this.removeChild(this.Newarrow1);
            return;
        }
    };
    GameControl.prototype.zhengshiStart = function () {
        //this.removeChild(UpgradeTishi);
        // this.removeChild(this.Newarrow);
        // this.removeChild(this.Newarrow1);
        /**新手指导 */
        //  this.empty1();//如果场景里存在金币，清除金币
        this.empty();
        this.count = 0;
        this.score = this.count;
        this.updateScore();
        this.upgradeNumber = 1;
        this.shareNum = 0;
        this.gun.bullet = 10;
        this.gun.updateNum((this.gun.bullet));
        this.BaozhaCount = 0;
        this.Textbaozha.text = this.BaozhaCount.toString();
        this.ChufaCount = 0;
        this.Textchufa.text = this.ChufaCount.toString();
        this.ZhongliCount = 0;
        this.Textzhongli.text = this.ZhongliCount.toString();
        this.FangdaCount = 0;
        this.Textfangda.text = this.FangdaCount.toString();
        this.onClick();
        this.sffaqiu = false;
        this.shangdan1();
        this.my_ball = [];
        this.boomNum = 0;
        this.m_PropManager.allProps = [];
        this.isOver = 0;
        this.upgradeNumber = 1;
        this.my_strikeBall = [];
        this.Striketime.chufashuzi = 3;
        this.Striketime.x = -100;
        this.Striketime.y = -100;
        this.Collidetime.x = -150;
        this.Collidetime.y = -150;
        this.overValue = 1;
        this.sendMsg(GameData.score);
    };
    /**选关界面继续按钮点击事件*/
    GameControl.prototype.onClick = function () {
        this.removeChild(this.bj);
        this.removeChild(this.btn);
        if (this.upgradeNumber3 != 0) {
            this.upgradeNumber3 = 0;
            this.upgradeNumber2 = 0;
            tanChuang = 0;
        }
    };
    /**激光道具粒子特效 */
    GameControl.prototype.xx = function (X, y) {
        SoundControl.getIns().addItem(MUSIC_CL);
        SoundControl.getIns().play(MUSIC_CL, 0, 1);
        var texture = RES.getRes("JiGuang_1_png");
        var config = RES.getRes("JiGuang_1_json");
        var particleSys = new particle.GravityParticleSystem(texture, config);
        particleSys.x = X - 330;
        particleSys.y = y - 220;
        this.addChild(particleSys);
        particleSys.start(300);
        var text = RES.getRes("JiGuang_1_png");
        var conf = RES.getRes("JiGuang_1_json");
        var particleSy = new particle.GravityParticleSystem(text, conf);
        particleSy.x = X + 340;
        particleSy.y = y + 217;
        particleSy.rotation = -180;
        this.addChild(particleSy);
        particleSy.start(300);
        /**新手指导 */
        if (tishi == 3) {
            //this.removeChild(this.Newjiantou);
            this.Newjiantou.x = 40;
            this.Newjiantou.y = 380;
            egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        }
        else if (tishi == 5) {
            this.Newjiantou.x = 280;
            this.Newjiantou.y = 530;
            egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        }
        else {
            this.Newjiantou.visible = false;
        }
    };
    GameControl.prototype.jiguangmei = function () {
        this.removeChild(this.Ball);
    };
    /**金币播放动画以及移动 */
    GameControl.prototype.goldFrameAnimation = function (point) {
        var _this = this;
        var texture2mc = RES.getRes("Gold_png");
        var data2mc = RES.getRes("Gold_json");
        var mcFactory = new egret.MovieClipDataFactory(data2mc, texture2mc);
        var mc = new egret.MovieClip(mcFactory.generateMovieClipData("Gold"));
        this.addChild(mc);
        mc.gotoAndPlay("Gold", 1); //"A" : Boom -1 ： 循环播放				
        mc.x = point.x - 60;
        mc.y = point.y - 60;
        mc.addEventListener(egret.Event.COMPLETE, function (e) {
            _this.removeChild(mc);
        }, this);
        //Tween动画
        var tw = egret.Tween.get(mc);
        tw.to({ x: 50, y: 50 }, 700);
    };
    /**改变颜色 */
    GameControl.prototype.changeColor = function () {
        // this.gun.ball.visible = false;
        // this.gun.redball.visible = false;
        // this.gun.magnify.visible = false;
        // this.gun.gravity.visible = false;
        // this.gun.strike.visible = false;
        // if (this.NowBullet.objkind == 301) {
        //     this.gun.ball.visible = true;
        // }
        // else if (this.NowBullet.objkind == 102) {
        //     this.gun.redball.visible = true;
        // }
        // else if (this.NowBullet.objkind == 103) {
        //     this.gun.magnify.visible = true;
        // } else if (this.NowBullet.objkind == 104) {
        //     this.gun.gravity.visible = true;
        // } else if (this.NowBullet.objkind == 105) {
        //     this.gun.strike.visible = true;
        // }
    };
    /**改变颜色 */
    GameControl.prototype.changeColor1 = function () {
        // this.gun.ball.visible = false;
        // this.gun.redball.visible = false;
        // this.gun.magnify.visible = false;
        // this.gun.gravity.visible = false;
        // this.gun.strike.visible = false;
        // if (this.NowBullet1.objkind == 301) {
        //     this.gun.ball.visible = true;
        // }
        // else if (this.NowBullet1.objkind == 102) {
        //     this.gun.redball.visible = true;
        // }
        // else if (this.NowBullet1.objkind == 103) {
        //     this.gun.magnify.visible = true;
        // } else if (this.NowBullet1.objkind == 104) {
        //     this.gun.gravity.visible = true;
        // } else if (this.NowBullet1.objkind == 105) {
        //     this.gun.strike.visible = true;
        // }
    };
    /**改变子弹 */
    GameControl.prototype.changeBullet = function () {
        this.NowBullet1 = this.fakeBullet;
        this.changeColor1();
    };
    /**碰撞 */
    GameControl.prototype.onHitBegin = function (evt) {
        var chishu = 0;
        var lizizhu = new egret.Point(0, 0);
        var zhonglei = -1;
        var ball;
        //将动态子弹赋值给ObjOne    静态道具、子弹赋值给ObjTwe
        if (evt.bodyA.userData.data.objkind == 301) {
            var objOne = evt.bodyA.userData.data;
            var objTwe = evt.bodyB.userData.data;
        }
        else if (evt.bodyB.userData.data.objkind == 301) {
            var objOne = evt.bodyB.userData.data;
            var objTwe = evt.bodyA.userData.data;
        }
        if (evt.bodyA.userData.data.objkind == 302) {
            var objOne = evt.bodyA.userData.data;
            var objTwe = evt.bodyB.userData.data;
        }
        else if (evt.bodyB.userData.data.objkind == 302) {
            var objOne = evt.bodyB.userData.data;
            var objTwe = evt.bodyA.userData.data;
        }
        else if (evt.bodyA.userData.data.objkind == 102) {
            var objOne = evt.bodyA.userData.data;
            var objTwe = evt.bodyB.userData.data;
        }
        else if (evt.bodyB.userData.data.objkind == 102) {
            var objOne = evt.bodyB.userData.data;
            var objTwe = evt.bodyA.userData.data;
        }
        else if (evt.bodyA.userData.data.objkind == 103) {
            var objOne = evt.bodyA.userData.data;
            var objTwe = evt.bodyB.userData.data;
        }
        else if (evt.bodyB.userData.data.objkind == 103) {
            var objOne = evt.bodyB.userData.data;
            var objTwe = evt.bodyA.userData.data;
        }
        else if (evt.bodyA.userData.data.objkind == 104) {
            var objOne = evt.bodyA.userData.data;
            var objTwe = evt.bodyB.userData.data;
        }
        else if (evt.bodyB.userData.data.objkind == 104) {
            var objOne = evt.bodyB.userData.data;
            var objTwe = evt.bodyA.userData.data;
        }
        else if (evt.bodyA.userData.data.objkind == 105) {
            var objOne = evt.bodyA.userData.data;
            var objTwe = evt.bodyB.userData.data;
        }
        else if (evt.bodyB.userData.data.objkind == 105) {
            var objOne = evt.bodyB.userData.data;
            var objTwe = evt.bodyA.userData.data;
        }
        //判断发射的子弹是普通的还是爆炸
        if (objOne.objkind == 301) {
            var bullet = objTwe.getCollision(objOne);
            if (bullet != null) {
                // this.getPoint(bullet);
                this.my_ball.push(bullet);
            }
            objOne.getCollision(objTwe);
            /*if (objTwe.objkind == 400) {
                // if (this.Collidetime.shuzi > 0) {//如果碰到一个球时（数字>0）
                //     // this.count += (this.Collidetime.shuzi + 1);//分翻倍
                //     // this.score = this.count;
                //     // this.updateScore();
                //     // this.gun.bullet = (this.gun.bullet) + ((this.Collidetime.shuzi) + 1);//自己的炮弹也是翻倍
                //     // this.gun.updateNum(this.gun.bullet)//更新炮弹
                // } else {
                //     // this.count += 1;
                //     // this.score = this.count;
                //     // this.updateScore();
                // this.gun.updateNum(++(this.gun.bullet));
                // }
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1])
                chishu = this.Collidetime.shuzi
                zhonglei = 0;
                this.liziy(lizizhu, zhonglei, chishu);
                zhonglei = 1;
            }
            if (objTwe.objkind == 401) {
                // this.propCount = this.Collidetime.shuzi + 1;
                // this.count += 0;
                // this.score = this.count;
                // this.NowBullet1 = this.boomBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1])
                chishu = this.Collidetime.shuzi
                zhonglei = 5;
            }
            if (objTwe.objkind == 402) {
                // if (this.Collidetime.shuzi > 0) {
                // this.propCount = this.Collidetime.shuzi + 1;
                // // }
                // this.count += 0;
                // this.score = this.count;
                // this.NowBullet1 = this.MagnifyBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1])
                chishu = this.Collidetime.shuzi
                zhonglei = 3;
                //   this.propCount = 1;

            }

            if (objTwe.objkind == 404) {
                // this.count += 0;
                // this.score = this.count;
            }
            if (objTwe.objkind == 405) {
                // this.propCount = this.Collidetime.shuzi + 1;
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.gravityBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1])
                chishu = this.Collidetime.shuzi
                zhonglei = 4;
            }
            if (objTwe.objkind == 406) {

                // this.count += 0;
                // this.score = this.count;
                // // this.propCount = 1;
                // this.NowBullet1 = this.strikeBullet;
                this.isChanger = 1;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1])
                chishu = this.Collidetime.shuzi
                zhonglei = 2;
            }
            if (objTwe.objkind == 108) {
                this.Striketime.updateNum(--(this.Striketime.chufashuzi));
                this.strikeChange();
                if (this.Striketime.chufashuzi == 0) {//碰撞满3次后消失

                    var bian1 = this.my_strikeBall.indexOf(objTwe);
                    this.my_strikeBall[bian1].removeBasicbullet(objTwe);
                    this.my_strikeBall.splice(bian1, 1);
                    this.removeChild(this.Striketime);
                    this.Striketime.chufashuzi = 3;


                }

            }
            if (this.isStrike == 1) {
                if (objTwe.objkind == 100) {
                    var bian = this.my_ball.indexOf(objTwe);
                    this.my_ball[bian].removeBasicbullet(objTwe);
                    this.my_ball.splice(bian, 1);
                }
            }*/
            if (objTwe.objkind == 100) {
                this.Collidetime.shuzi++;
                this.Collidetime.updateNum(this.Collidetime.shuzi); //更改碰撞显示次数
                console.log(this.Collidetime.shuzi);
                ++this.jiaQiuCount; //9999 
            }
            //碰撞到球
            if (objTwe.objkind == 500) {
                if (this.istop && this.playTwoHp > 0) {
                    this.playOneHp--;
                }
                if (!this.istop && this.playOneHp > 0) {
                    this.playTwoHp--;
                }
            }
            //碰撞到蓝色砖块
            if (objTwe.objkind == 600) {
                objTwe.m_num--;
                this.Collidetime.updateNum(++this.Collidetime.shuzi); //更改碰撞显示次数
                ++this.jiaQiuCount;
                /* if(this.istop)
                 {
                  this.zhuanTXT.text=this.zhuan.m_num.toString();
                 }
                 else if(!this.istop)
                 {
                  this.zhuanTopTXT.text=this.zhuanTop.m_num.toString();
                 }*/
                if (objTwe.m_num <= 0) {
                    objTwe.setPostion(-600, -600);
                }
            }
        }
        else if (objOne.objkind == 103) {
            // objTwe.getCollision(objOne);
            // objOne.getCollision(objTwe);
            var bullet = objTwe.getCollision(objOne);
            if (bullet != null) {
                // this.getPoint(bullet);
                this.my_ball.push(bullet);
            }
            objOne.getCollision(objTwe);
            if (objTwe.objkind == 400) {
                // this.count += 1;
                // this.score = this.count;
                // this.updateScore();
                // this.gun.updateNum(++(this.gun.bullet));
                // // if (this.propCount == 0) {//道具数量为0 才能更改子弹
                //   this.changeBullet();
                // // }
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 0;
                this.liziy(lizizhu, zhonglei, chishu);
                zhonglei = 1;
                if (this.gun.bullet <= 0) {
                    this.isOver = 1;
                    this.over();
                }
            }
            else if (objTwe.objkind == 401) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.boomBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 5;
            }
            else if (objTwe.objkind == 403) {
                // this.count += 0;
                // this.score = this.count;
                this.my_ball = [];
            }
            else if (objTwe.objkind == 404) {
                // this.count += 0;
                // this.score = this.count;
            }
            else if (objTwe.objkind == 402) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.MagnifyBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 3;
            }
            else if (objTwe.objkind == 405) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.gravityBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 4;
            }
            else if (objTwe.objkind == 406) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.strikeBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 2;
            }
            else if (objTwe.objkind == 100) {
                this.Collidetime.updateNum(++(this.Collidetime.shuzi)); //更改碰撞显示次数
                ++this.jiaQiuCount; //9999
            }
            else if (objTwe.objkind == 108) {
                this.Striketime.updateNum(--(this.Striketime.chufashuzi));
                this.strikeChange();
                if (this.Striketime.chufashuzi == 0) {
                    var bian1 = this.my_strikeBall.indexOf(objTwe);
                    this.my_strikeBall[bian1].removeBasicbullet(objTwe);
                    this.my_strikeBall.splice(bian1, 1);
                    this.removeChild(this.Striketime);
                    this.Striketime.chufashuzi = 3;
                }
            }
            else if (this.isStrike == 1) {
                if (objTwe.objkind == 100) {
                    var bian = this.my_ball.indexOf(objTwe);
                    this.my_ball[bian].removeBasicbullet(objTwe);
                    this.my_ball.splice(bian, 1);
                }
            }
            // else {
            //     if (this.propCount == 0) {//道具数量为0 才能更改子弹
            //         this.changeBullet();
            //     }
            // }
        }
        else if (objOne.objkind == 102) {
            var bullet = objTwe.getCollision(objOne);
            if (bullet != null) {
                // this.getPoint(bullet);
                this.my_ball.push(bullet);
            }
            objOne.getCollision(objTwe);
            if (objTwe.objkind == 400) {
                // this.count += 1;
                // this.score = this.count;
                // this.updateScore();
                // this.gun.updateNum(++(this.gun.bullet));
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 0;
                this.liziy(lizizhu, zhonglei, chishu);
                zhonglei = 1;
                if (this.gun.bullet <= 0) {
                    this.isOver = 1;
                    this.over();
                }
            }
            if (objTwe.objkind == 401) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.boomBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 5;
            }
            if (objTwe.objkind == 402) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.MagnifyBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 3;
            }
            if (objTwe.objkind == 405) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.gravityBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 4;
            }
            if (objTwe.objkind == 406) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.strikeBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 2;
            }
            if (objTwe.objkind == 404) {
                // this.count += 0;
                // this.score = this.count;
            }
            if (objTwe.objkind == 100) {
                this.Collidetime.updateNum(++(this.Collidetime.shuzi)); //更改碰撞显示次数
                ++this.jiaQiuCount; //9999
            }
            if (objTwe.objkind == 108) {
                this.Striketime.updateNum(--(this.Striketime.chufashuzi));
                this.strikeChange();
                if (this.Striketime.chufashuzi == 0) {
                    var bian1 = this.my_strikeBall.indexOf(objTwe);
                    this.my_strikeBall[bian1].removeBasicbullet(objTwe);
                    this.my_strikeBall.splice(bian1, 1);
                    this.removeChild(this.Striketime);
                    this.Striketime.chufashuzi = 3;
                }
            }
            if (this.isStrike == 1) {
                if (objTwe.objkind == 100) {
                    var bian = this.my_ball.indexOf(objTwe);
                    this.my_ball[bian].removeBasicbullet(objTwe);
                    this.my_ball.splice(bian, 1);
                }
            }
        }
        else if (objOne.objkind == 104) {
            var bullet = objTwe.getCollision(objOne);
            if (bullet != null) {
                // this.getPoint(bullet);
                this.my_ball.push(bullet);
            }
            objOne.getCollision(objTwe);
            if (objTwe.objkind == 400) {
                // this.count += 1;
                // this.score = this.count;
                // this.updateScore();
                // this.gun.updateNum(++(this.gun.bullet));
                // if (this.propCount == 0) {//道具数量为0 才能更改子弹
                //     this.changeBullet();
                // }
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 0;
                this.liziy(lizizhu, zhonglei, chishu);
                zhonglei = 1;
                if (this.gun.bullet <= 0) {
                    this.isOver = 1;
                    this.over();
                }
            }
            else if (objTwe.objkind == 401) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.boomBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 5;
            }
            else if (objTwe.objkind == 403) {
                // this.count += 0;
                // this.score = this.count;
                this.my_ball = [];
            }
            else if (objTwe.objkind == 405) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.gravityBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 4;
            }
            else if (objTwe.objkind == 404) {
                // this.count += 0;
                // this.score = this.count;
            }
            else if (objTwe.objkind == 402) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.MagnifyBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 3;
            }
            else if (objTwe.objkind == 406) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.strikeBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 2;
            }
            else if (objTwe.objkind == 100) {
                this.Collidetime.updateNum(++(this.Collidetime.shuzi)); //更改碰撞显示次数
                ++this.jiaQiuCount; //9999
            }
            else if (objTwe.objkind == 108) {
                this.Striketime.updateNum(--(this.Striketime.chufashuzi));
                this.strikeChange();
                if (this.Striketime.chufashuzi == 0) {
                    var bian1 = this.my_strikeBall.indexOf(objTwe);
                    this.my_strikeBall[bian1].removeBasicbullet(objTwe);
                    this.my_strikeBall.splice(bian1, 1);
                    this.removeChild(this.Striketime);
                    this.Striketime.chufashuzi = 3;
                }
            }
            else if (objTwe.objkind == 100) {
                if (this.isStrike == 1) {
                    var bian = this.my_ball.indexOf(objTwe);
                    this.my_ball[bian].removeBasicbullet(objTwe);
                    this.my_ball.splice(bian, 1);
                }
            }
            // else {
            //     if (this.propCount == 0) {//道具数量为0 才能更改子弹
            //         this.changeBullet();
            //     }
            // }
            if (this.bianliang == 1) {
                if (objTwe.objkind == 100) {
                    // this.my_ball[0].removeBasicbullet(objTwe);
                    // this.my_ball.splice(0, 1);
                    var bian2 = this.my_ball.indexOf(objTwe); //查到下标值
                    this.my_ball[bian2].removeBasicbullet(objTwe);
                    this.my_ball.splice(bian2, 1);
                }
            }
        }
        else if (objOne.objkind == 105) {
            var bullet = objTwe.getCollision(objOne);
            if (bullet != null) {
                // this.getPoint(bullet);
                this.my_ball.push(bullet);
            }
            objOne.getCollision(objTwe);
            if (objTwe.objkind == 400) {
                // this.count += 1;
                // this.score = this.count;
                // this.updateScore();
                // this.gun.updateNum(++(this.gun.bullet));
                // if (this.propCount == 0) {//道具数量为0 才能更改子弹
                //     this.changeBullet();
                // }
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 0;
                this.liziy(lizizhu, zhonglei, chishu);
                zhonglei = 1;
                if (this.gun.bullet <= 0) {
                    this.isOver = 1;
                    this.over();
                }
            }
            else if (objTwe.objkind == 401) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.boomBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 5;
            }
            else if (objTwe.objkind == 402) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.MagnifyBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 3;
            }
            else if (objTwe.objkind == 405) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.gravityBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 4;
            }
            else if (objTwe.objkind == 406) {
                // this.count += 0;
                // this.score = this.count;
                // this.propCount = 1;
                // this.NowBullet1 = this.strikeBullet;
                lizizhu = new egret.Point(objTwe.m_body.position[0], objTwe.m_body.position[1]);
                chishu = this.Collidetime.shuzi;
                zhonglei = 2;
            }
            else if (objTwe.objkind == 404) {
                this.count += 0;
                this.score = this.count;
            }
            else if (objTwe.objkind == 100) {
                this.Collidetime.updateNum(++(this.Collidetime.shuzi)); //更改碰撞显示次数
                ++this.jiaQiuCount; //9999
            }
            // else {
            //     if (this.propCount == 0) {//道具数量为0 才能更改子弹
            //         this.changeBullet();
            //     }
            // }
        }
        // if (objTwe.objkind == 200 || objTwe.objkind == 201) {
        if (this.propCount <= 0 && this.isChanger == 0) {
            this.changeBullet();
        }
        // }
        // if (this.boomNum >= 4) {//当前子弹操作结束 第五发子弹才会是爆炸弹
        //     if (this.NowBullet1 != null) {
        //         if (this.NowBullet1.objkind == 103) {
        //             this.NowBullet1 = this.MagnifyBullet;
        //         } else if (this.NowBullet1.objkind == 102) {
        //             this.NowBullet1 = this.boomBullet;
        //         } else if (this.NowBullet1.objkind == 104) {
        //             this.NowBullet1 = this.gravityBullet;
        //         } else if (this.NowBullet1.objkind == 105) {
        //             this.NowBullet1 = this.strikeBullet;
        //         }
        //         else {
        //             this.NowBullet1 = this.boomBullet;
        //             this.boomNum = 0;
        //         }
        //     }
        //     if (this.boomNum == 4 && this.NowBullet1 == null) {//第五发子弹改为爆炸子弹
        //         this.NowBullet1 = this.boomBullet;
        //         this.boomNum = 0;
        //     }
        //     this.isChanger = 1;
        // }
        // if (this.boomNum == 5) {
        //     this.NowBullet1 = this.boomBullet;
        //    this.boomNum = 0;
        //     this.isChanger = 1;
        // }
        // this.changeColor();//改变下个球的颜色 
        // if (this.NowBullet1 != null) {
        //     this.changeColor1();//改变下个球的颜色 
        //     // if(this.NowBullet1.objkind==103)
        //     // {
        //     //     this.e=45;
        //     // }
        //     // else
        //     // {
        //     //     this.e=13;
        //     // }
        // }
        this.count += 0;
        this.score = this.count;
        if (zhonglei != -1) {
            console.log("**********" + zhonglei);
            this.liziy(lizizhu, zhonglei, this.jiaQiuCount);
        }
        if (objTwe.objkind == 200 || objTwe.objkind == 201) {
            if (this.huiheNum >= 2) {
                this.istop = !this.istop;
                this.qiehuan = false;
                this.huiheNum = 0;
            }
            this.Collidetime.shuzi = 0;
            this.Collidetime.txtNum1.visible = false;
            this.fashe.visible = true;
            this.adjustment.visible = true;
            if (tishi == 5 || tishi == 6 || tishi == 7 || tishi == 8) {
                tanChuang = 2;
            }
            this.NowBullet.m_body.velocity = [0, 0];
            this.NowBullet.setPostion(-10110, -14547);
            this.NowBullet.isRun == false;
            if (this.isOver == 0) {
                if (this.gun.bullet <= 0 && this.NowBullet.isRun == false && this.Collidetime.shuzi <= 0) {
                    this.isOver = 1;
                    this.over();
                }
                else if (this.gun.bullet <= 0 && this.NowBullet.isRun == false) {
                    this.isOver = 1;
                    this.over();
                }
                else if (this.gun.bullet <= 0) {
                    this.isOver = 1;
                    this.over();
                }
            }
        }
        if (this.gun.bullet <= 0 && this.NowBullet.isRun == false && zhonglei != 1) {
            this.isOver = 1;
            this.over();
        }
        if (this.m_PropManager.m_props1.length > 0) {
            if (this.m_PropManager.m_props1[0].objkind == 400) {
                this.m_PropManager.removePorp1(this.m_PropManager.m_props1[0]);
            }
        }
        tanChuang = 0;
    };
    GameControl.prototype.judgeOver = function () {
        this.NowBullet.runEnd1();
        this.isStrike = 1;
    };
    GameControl.prototype.strikeChange = function () {
        this.OverTimer = new egret.Timer(100, 1);
        this.OverTimer.start(); //开始计时
        this.OverTimer.addEventListener(egret.TimerEvent.TIMER, this.judgeOver, this); //计时中事件
    };
    // /**判断是否死亡 */
    // public judgeOver() {
    //     if (this.gun.bullet <= 0 && this.NowBullet.isRun == false) {
    //         this.over();
    //     }
    // }
    // //计算与重力球接触的基本球
    // public gravityResult(X: number, Y: number) {
    //     for (var i = 0; i < this.my_ball.length; i++) {
    //         let p1 = new egret.Point;
    //         p1.x = X;
    //         p1.y = Y;
    //         let p2 = new egret.Point;
    //         p2.x = this.my_ball[i].m_body.position[0];
    //         p2.y = this.my_ball[i].m_body.position[1];
    //         //判断距离  小于一定距离销毁球
    //         if (this.zhonglijisuan(p1, p2) && this.my_ball[i].objkind == 100) {
    //             this.my_ball[i].removeBasicbullet(this.my_ball[i]);
    //             this.my_ball.splice(i, 1);
    //             i--;
    //         }
    //     }
    //     // this.removeEventListener(egret.Event.ENTER_FRAME, this.chuanweizhi, this);
    // }
    GameControl.prototype.laserResult = function (X, Y) {
        this.xx(X, Y); //激光帧动画 预留
        for (var i = 0; i < this.my_ball.length; i++) {
            var p1 = new egret.Point;
            p1.x = X;
            p1.y = Y;
            var p2_1 = new egret.Point;
            p2_1.x = this.my_ball[i].m_body.position[0];
            p2_1.y = this.my_ball[i].m_body.position[1];
            //判断距离  小于一定距离销毁球
            if (this.getRightball(p1, p2_1) && this.my_ball[i].objkind == 100) {
                this.my_ball[i].removeBasicbullet(this.my_ball[i]);
                this.my_ball.splice(i, 1);
                i--;
            }
        }
        if (this.propCount == 0) {
            this.changeBullet();
        }
    };
    GameControl.prototype.bombBlasts = function (X, Y) {
        this.frameAnimation(X, Y);
        //销毁子弹判断
        for (var i = 0; i < this.my_ball.length; i++) {
            var p1 = new egret.Point;
            p1.x = X;
            p1.y = Y;
            var p2_2 = new egret.Point;
            p2_2.x = this.my_ball[i].m_body.position[0];
            p2_2.y = this.my_ball[i].m_body.position[1];
            //判断距离  小于一定距离销毁球
            if (this.getDisPTOP(p1, p2_2) && this.my_ball[i].objkind == 100) {
                this.my_ball[i].removeBasicbullet(this.my_ball[i]);
                this.my_ball.splice(i, 1);
                i--;
            }
        }
        //销毁道具判断
        // var my_prop = this.m_PropManager.m_props1;
        var my_prop = this.m_PropManager.allProps;
        for (var i = 0; i < my_prop.length; i++) {
            var p1 = new egret.Point;
            p1.x = X;
            p1.y = Y;
            var p2_3 = new egret.Point;
            p2_3.x = my_prop[i].m_body.position[0];
            p2_3.y = my_prop[i].m_body.position[1];
            //判断距离  小于一定距离销毁球
            if (this.getDisPTOP(p1, p2_3) && my_prop[i].objkind == 401) {
                this.m_PropManager.removePorp1(this.m_PropManager.allProps[i]);
                // this.m_PropManager.m_props1.splice(i, 1);
                // i--;
            }
            if (this.getDisPTOP(p1, p2_3) && my_prop[i].objkind == 402) {
                this.m_PropManager.removePorp1(this.m_PropManager.allProps[i]);
            }
            if (this.getDisPTOP(p1, p2_3) && my_prop[i].objkind == 404) {
                this.m_PropManager.removePorp1(this.m_PropManager.allProps[i]);
            }
            if (this.getDisPTOP(p1, p2_3) && my_prop[i].objkind == 405) {
                this.m_PropManager.removePorp1(this.m_PropManager.allProps[i]);
            }
            if (this.getDisPTOP(p1, p2_3) && my_prop[i].objkind == 406) {
                this.m_PropManager.removePorp1(this.m_PropManager.allProps[i]);
            }
            if (this.getDisPTOP(p1, p2_3) && my_prop[i].objkind == 400) {
                this.m_PropManager.removePorp(this.m_PropManager.allProps[i]);
            }
        }
        if (this.propCount == 0) {
            this.changeBullet();
        }
        this.changeColor();
    };
    /**爆炸球碰到金币 */
    GameControl.prototype.crashGold = function () {
        if (this.propCount == 0) {
            this.changeBullet();
        }
        this.changeColor();
    };
    /**计算点到点距离 */
    GameControl.prototype.getDisPTOP = function (P1, p2) {
        var num1 = (P1.x - p2.x) * (P1.x - p2.x);
        var num2 = (P1.y - p2.y) * (P1.y - p2.y);
        var num = Math.sqrt((num1 + num2));
        var bool = false;
        if (num <= 130) {
            bool = true;
        }
        return bool;
    };
    /**符合激光效果计算 */
    GameControl.prototype.getRightball = function (P1, p2) {
        var bool = false;
        if (p2.y > ((P1.y) - 20) && p2.y < ((P1.y) + 30)) {
            bool = true;
        }
        return bool;
    };
    // /**符合重力球的效果计算 */
    // public zhonglijisuan(P1: egret.Point, p2: egret.Point) {
    //     var bool = false;
    //     if (p2.y - P1.y <= 80 && p2.x > P1.x - 40 && p2.x < P1.x + 40) {// P1.x > p2.x - 30 && P1.x < p2.x + 30
    //         bool = true;
    //     }
    //     if (P1.x == -200 && P1.y == -200) {
    //         this.removeEventListener(egret.Event.ENTER_FRAME, this.position, this);
    //         console.log("操作已完成，关闭传值");
    //     }
    //     if (P1.x == -100 && P1.y == -100) {
    //         this.removeEventListener(egret.Event.ENTER_FRAME, this.position, this);
    //         console.log("操作已完成，关闭传值100");
    //     }
    //     return bool;
    // }
    GameControl.prototype.setBallImpulse = function (ball) {
        var x = Math.random() > 0.5 ? -5000 : 5000;
        var y = -5000 - (Math.random() * 2000);
        ball.applyImpulse([x, y], [0, 0]);
    };
    GameControl.prototype.addPoint = function (addpoint) {
        this.score = this.score + addpoint;
    };
    /**更新分数 */
    GameControl.prototype.updateScore = function () {
        this.txtScore.text = this.score.toString();
        this.txtScore.x = 100;
        this.txtScore.y = 25;
        this.txtScore.textColor = 0xf06f00;
        this.Collidetime.shuzi = 0; //加分不叠加，清空前一轮碰撞数据
        this.txtScore.visible = false;
        //  this.shishi.text = "00";
    };
    /**按下*/
    GameControl.prototype.startBackFun = function (pos) {
        if (this.NowBullet.isRun == false) {
            if (this.istop) {
                this.guntop.showLine();
            }
            if (!this.istop) {
                this.gun.showLine();
            }
            //this.controlGun.close();
            if (pos.x < 159 && pos.x > 468 && pos.y < 712 && pos.y > 1032 || this.panshu == 0) {
                this.zhuobiao = pos;
                this.controlMove1(pos);
                this.shape.visible = true;
            }
            this.controlMove(pos);
        }
        //this.controlGun.close();
        //this.my_ball.push(this.m_PropManager.m_props[0]);
        //this.getPoint(this.m_PropManager.m_props[0]);
        if (this.gun.lineBool) {
            this.shape.visible = true;
        }
        this.shape1.visible = false;
        // if (tishi == 4 && this.upgradeNumber3 != 0) {
        // this.removeChild(this.bj);
        // this.upgradeNumber4 = 0;
        // this.upgradeNumber3 = 0;
        // this.upgradeNumber2 = 0;
        // }
        //         if(tanChuang==2){
        //  if ((tishi == 5 || tishi == 8) && this.upgradeNumber3 != 0) {
        //             this.Newjiantou.visible = true;
        //             this.Newjiantou.x = 360;
        //             this.Newjiantou.y = 560;
        //             egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        //             this.removeChild(this.bj);
        //             this.upgradeNumber4 = 0;
        //             this.upgradeNumber3 = 0;
        //             tanChuang=0;
        //             this.upgradeNumber2 = 0;
        //             this.Newarrow.visible=false;
        //         }
        //         // console.log("weqwddbwerwrw提示" + tishi);
        //         if (tishi == 6 && this.upgradeNumber3 != 0) {
        //             this.Newjiantou.visible = true;
        //             this.Newjiantou.x = 90;
        //             this.Newjiantou.y = 460;
        //             egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        //             this.removeChild(this.bj);
        //             this.upgradeNumber4 = 0;
        //             this.upgradeNumber3 = 0;
        //             tanChuang=0;
        //             this.upgradeNumber2 = 0;
        //             this.Newarrow.visible=false;
        //         }
        //         if (tishi == 7 && this.upgradeNumber3 != 0) {
        //             this.Newjiantou.visible = true;
        //             this.Newjiantou.x = 360;
        //             this.Newjiantou.y = 260;
        //             egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
        //             this.removeChild(this.bj);
        //             this.upgradeNumber4 = 0;
        //             this.upgradeNumber3 = 0;
        //             tanChuang=0;
        //             this.upgradeNumber2 = 0;
        //             this.Newarrow.visible=false;
        //         }
        //         }
        if (tanChuang == 1) {
            if (tishi == 2 && this.upgradeNumber3 != 0) {
                this.removeChild(this.bj);
                this.upgradeNumber4 = 3;
                this.upgradeNumber3 = 0;
                tanChuang = 0;
                var timer2 = new egret.Timer(500, 1);
                //注册事件侦听器
                timer2.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerComFunc22, this);
                //开始计时
                timer2.start();
                this.upgradeNumber2 = 0;
                this.Newarrow.visible = false;
                this.Newarrow1.visible = false;
            }
            if (tishi == 3 && this.upgradeNumber3 != 0) {
                this.addChild(this.Newjiantou);
                this.Newjiantou.x = 360;
                this.Newjiantou.y = 560;
                this.Newjiantou.rotation = -30;
                egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                this.removeChild(this.bj);
                this.upgradeNumber4 = 0;
                this.upgradeNumber3 = 0;
                tanChuang = 0;
                this.upgradeNumber2 = 0;
                this.Newarrow.visible = false;
                this.Newarrow1.visible = false;
            }
            if (tishi == 4 && this.upgradeNumber3 != 0) {
                this.Newjiantou.visible = true;
                this.Newjiantou.x = 60;
                this.Newjiantou.y = 210;
                egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                this.removeChild(this.bj);
                this.upgradeNumber4 = 0;
                this.upgradeNumber3 = 0;
                tanChuang = 0;
                this.upgradeNumber2 = 0;
                this.Newarrow.visible = false;
            }
            if ((tishi == 5 || tishi == 8) && this.upgradeNumber3 != 0) {
                this.Newjiantou.visible = true;
                this.Newjiantou.x = 360;
                this.Newjiantou.y = 560;
                egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                this.removeChild(this.bj);
                this.upgradeNumber4 = 0;
                this.upgradeNumber3 = 0;
                tanChuang = 0;
                this.upgradeNumber2 = 0;
                this.Newarrow.visible = false;
            }
            // console.log("weqwddbwerwrw提示" + tishi);
            if (tishi == 6 && this.upgradeNumber3 != 0) {
                this.Newjiantou.visible = true;
                this.Newjiantou.x = 90;
                this.Newjiantou.y = 460;
                egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                this.removeChild(this.bj);
                this.upgradeNumber4 = 0;
                this.upgradeNumber3 = 0;
                tanChuang = 0;
                this.upgradeNumber2 = 0;
                this.Newarrow.visible = false;
            }
            if (tishi == 7 && this.upgradeNumber3 != 0) {
                this.Newjiantou.visible = true;
                this.Newjiantou.x = 360;
                this.Newjiantou.y = 260;
                egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                this.removeChild(this.bj);
                this.upgradeNumber4 = 0;
                this.upgradeNumber3 = 0;
                tanChuang = 0;
                this.upgradeNumber2 = 0;
                this.Newarrow.visible = false;
            }
        }
    };
    GameControl.prototype.updatePoint = function (pos) {
        var r = 180 - Math.atan2(pos.x, pos.y) * 180 / Math.PI;
        var pit = new egret.Point();
        this.shape1.visible = true;
        this.shape1.$anchorOffsetX = this.gun.x;
        this.shape1.$anchorOffsetY = this.gun.y;
        this.shape1.x = this.gun.x;
        this.shape1.y = this.gun.y;
        this.shape1.rotation = r;
    };
    GameControl.prototype.getPoint = function (p) {
        // for (var k = 1; k <= 360; k += 3) {
        //     var pit = new egret.Point();
        //     if (p.objkind == 100) {
        //         pit.x = p.m_body.position[0] + 15 * Math.cos(k * Math.PI / 180);
        //         pit.y = p.m_body.position[1] + 15 * Math.sin(k * Math.PI / 180);
        //     }
        //     else {
        //         pit.x = p.m_body.position[0] + 30 * Math.cos(k * Math.PI / 180);
        //         pit.y = p.m_body.position[1] + 30 * Math.sin(k * Math.PI / 180);
        //     }
        //     p.pointList.push(pit);
        // }
    };
    /**找到最近的球 */
    GameControl.prototype.getRaycastProps = function (startx, starty, endx, endy) {
        var mindis = 30;
        var min = 1000;
        var nearestBall = null; //最近的球
        for (var i = 0; i < this.my_ball.length; ++i) {
            var ball = this.my_ball[i];
            var zuobiao1 = new egret.Point(this.gun.x, this.gun.y);
            var zuobiao2 = new egret.Point(this.my_ball[i].m_body.position[0], this.my_ball[i].m_body.position[1]);
            var juli = egret.Point.distance(zuobiao1, zuobiao2);
            var dis = py2Obj.MathUtils.getDistanceBetweenPointAndLine(startx, starty, endx, endy, ball.m_body.position[0], ball.m_body.position[1], this);
            //   console.log("XXXXXXXXXXXXXXXXXXXX" + dis);
            if (dis < this.e + 13) {
                if (juli < min) {
                    min = juli;
                    nearestBall = this.my_ball[i];
                }
            }
        }
        if (nearestBall != null) {
            //console.log("mindis" + mindis + "zuobiao" + nearestBall.m_body.position[0] + "," + nearestBall.m_body.position[1]);
        }
        return nearestBall;
    };
    GameControl.prototype.playcl1 = function () {
        if (this.playpd) {
            this.playpd = false;
        }
    };
    GameControl.prototype.controlMove = function (posMove) {
        var g_un;
        if (this.istop) {
            g_un = this.guntop;
        }
        if (!this.istop) {
            g_un = this.gun;
        }
        if (Math.sqrt(Math.pow(posMove.x - 315, 2) + Math.pow(posMove.y - 875, 2)) <= this.Weitiaojuli) {
            this.playpd = true; //控制声音
            this.faguang = true;
            if (this.zhuobiao != null && this.NowBullet.isRun == false) {
                if (posMove.y < 886 && posMove.x >= 319) {
                    if (posMove.x < this.zhuobiao.x || posMove.y < this.zhuobiao.y) {
                        this.rr -= 0.1;
                        this.faan.rotation -= 0.6;
                    }
                    if (posMove.x > this.zhuobiao.x || posMove.y > this.zhuobiao.y) {
                        this.rr += 0.1;
                        this.faan.rotation += 0.6;
                    }
                }
                else if (posMove.y <= 886 && posMove.x < 319) {
                    if (posMove.x < this.zhuobiao.x || posMove.y > this.zhuobiao.y) {
                        this.rr -= 0.1;
                        this.faan.rotation -= 0.6;
                    }
                    if (posMove.x > this.zhuobiao.x || posMove.y < this.zhuobiao.y) {
                        this.rr += 0.1;
                        this.faan.rotation += 0.6;
                    }
                }
                else if (posMove.y > 886 && posMove.x <= 319) {
                    if (posMove.x > this.zhuobiao.x || posMove.y > this.zhuobiao.y) {
                        this.rr -= 0.1;
                        this.faan.rotation -= 0.6;
                    }
                    if (posMove.x < this.zhuobiao.x || posMove.y < this.zhuobiao.y) {
                        this.rr += 0.1;
                        this.faan.rotation += 0.6;
                    }
                }
                else {
                    if (posMove.x > this.zhuobiao.x || posMove.y < this.zhuobiao.y) {
                        this.rr -= 0.1;
                        this.faan.rotation -= 0.6;
                    }
                    if (posMove.x < this.zhuobiao.x || posMove.y > this.zhuobiao.y) {
                        this.rr += 0.1;
                        this.faan.rotation += 0.6;
                    }
                }
                var aa = -Math.sin(this.rr / 57.3) * 20;
                var bb = Math.cos(this.rr / 57.3) * 20;
                this.fashezhuo = new egret.Point((aa + g_un.x), (bb + g_un.y));
                this.controlMove1(this.fashezhuo);
            }
        }
        else {
            this.playpd = false;
            this.faguang = false;
            this.fashezhuo = new egret.Point(posMove.x, posMove.y);
            this.controlMove1(this.fashezhuo);
        }
        this.zhuobiao = posMove; //{ x: posMove.x, y: posMove.y };
    };
    GameControl.prototype.controlMove1 = function (posMove) {
        var g_un;
        if (this.istop) {
            g_un = this.guntop;
        }
        if (!this.istop) {
            g_un = this.gun;
        }
        this.panshu = 1;
        var pos = new egret.Point((posMove.x - g_un.x), (posMove.y - g_un.y));
        g_un.updatePos(pos);
        var r = -Math.atan2(pos.x, pos.y) * 180 / Math.PI;
        this.rr = r;
        var ptFrom = { x: g_un.x, y: g_un.y };
        var ptTo = { x: 0, y: 0 };
        var angle = Math.atan2(pos.x, pos.y);
        ptTo = { x: ptFrom.x + Math.sin(angle) * 1000, y: ptFrom.y + Math.cos(angle) * 1000 }; //1000
        var ray = new p2.Ray({ from: [ptFrom.x, ptFrom.y], to: [ptTo.x, ptTo.y], mode: p2.Ray.CLOSEST });
        var nearstBall;
        nearstBall = this.getRaycastProps(ptFrom.x, ptFrom.y, ptTo.x, ptTo.y);
        if (nearstBall != null) {
            this.shape1.visible = false;
            var nextPos = { x: ptFrom.x, y: ptFrom.y };
            var dis = 1000;
            var bool = false;
            while (dis > this.e + 13) {
                if (egret.Point.distance(egret.Point.create(ptFrom.x, ptFrom.y), egret.Point.create(nextPos.x, nextPos.y)) > 1100) {
                    bool = true;
                    break;
                }
                nextPos = { x: nextPos.x + ray.direction[0] * 16.666062908012332, y: nextPos.y + ray.direction[1] * 16.666062908012332 };
                dis = Math.sqrt((nextPos.x - nearstBall.m_body.position[0]) * (nextPos.x - nearstBall.m_body.position[0]) + (nextPos.y - nearstBall.m_body.position[1]) * (nextPos.y - nearstBall.m_body.position[1]));
            }
            var ptIns = { x: nextPos.x, y: nextPos.y };
            this.shape.graphics.clear();
            // this.shape.graphics.beginFill(0xf8f8ff,1);
            // this.shape.graphics.lineStyle(2, 0x00ff00);
            // //出发的线
            // this.shape.graphics.moveTo(ptFrom.x, ptFrom.y);
            // this.shape.graphics.lineTo(ptTo.x, ptTo.y);
            if (bool == false) {
                //预测碰撞位置 
                this.shape.graphics.lineStyle(3, 0xf8f8ff); //0xf8f8ff
                // this.shape.graphics.moveTo(this.gun.x, this.gun.y);
                // this.shape.graphics.lineTo(ptIns.x, ptIns.y);
                this.shape.graphics.lineStyle(1, 0xffe7be); //改变圆的颜色 
                this.shape.graphics.drawCircle(ptIns.x, ptIns.y, this.e);
                //球心联系
                this.shape.graphics.moveTo(ptIns.x, ptIns.y);
                // this.shape.graphics.lineTo(nearstBall.m_body.position[0], nearstBall.m_body.position[1]);
                //  console.log("|||||||||||||||**************" + ptIns1.x +"," +ptIns1.y + "V" + + ptIns2.x +"," +ptIns2.y );
                var rayOut = p2.vec2.clone([0, 0]);
                var rayDir = p2.vec2.clone([0, 0]);
                p2.vec2.normalize(rayDir, [ptFrom.x - ptTo.x, ptFrom.y - ptTo.y]);
                var rayNor = p2.vec2.clone([0, 0]);
                p2.vec2.normalize(rayNor, [ptIns.y - nearstBall.m_body.position[1], -ptIns.x + nearstBall.m_body.position[0]]);
                p2.vec2.reflect(rayOut, rayDir, rayNor);
                //   console.log(rayOut[0] + "{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}" + rayOut[1]);
                //垂线
                this.shape.graphics.moveTo(ptIns.x, ptIns.y);
                if (ptIns.x >= nearstBall.m_body.position[0]) {
                    this.shape.graphics.lineTo(ptIns.x + rayNor[0], ptIns.y + rayNor[1]);
                }
                else if (ptIns.x < nearstBall.m_body.position[0]) {
                    this.shape.graphics.lineTo(ptIns.x + rayNor[0], ptIns.y + rayNor[1]);
                }
                this.shape.graphics.lineStyle(1, 0xffe7be); //
                this.shape.graphics.moveTo(ptIns.x, ptIns.y);
                this.shape.graphics.lineTo(ptIns.x + rayOut[0] * 100, ptIns.y + rayOut[1] * 100);
                // this.shape.graphics.lineStyle(2, 0x0000ff);//蓝色
                var d = egret.Point.distance(egret.Point.create(ptIns.x, ptIns.y), egret.Point.create(g_un.x, g_un.y)); //碰撞点 与炮的位置 之间的距离
                var bili = d / g_un.line.height; //线的缩放比例
                g_un.line.scaleY = bili;
                if (bili < 0.2) {
                    g_un.line.scaleX = 0.5;
                }
                //this.qiudong(ptIns.x, ptIns.y);
            }
            // this.qiudong(ptIns.x, ptIns.y);
            //反射线
            //入射线
            //  this.shape.graphics.lineStyle(2, 0x00ff00);//绿色
            // this.shape.graphics.moveTo(ptIns.x, ptIns.y);
            //  this.shape.graphics.lineTo(ptIns.x +ray.direction[0] *10,ptIns.y +ray.direction[1] *10 );
            this.shape.graphics.endFill();
            this.addChild(this.shape);
        }
        else {
            g_un.line.scaleY = 1; //线的缩放
            g_un.line.scaleX = 1;
            this.updatePoint(pos);
            this.shape.graphics.clear();
        }
        if (this.NowBullet.isRun) {
            this.shape.graphics.clear();
        }
    };
    GameControl.prototype.qiudong = function (X, Y) {
        //Tween动画
        var tw = egret.Tween.get(this.NowBullet);
        tw.to({ x: X, y: Y }, 1000);
    };
    GameControl.prototype.endBackFun1 = function () {
        if (this.upgradeNumber3 == 0 || this.upgradeNumber2 == 100) {
            this.fenxiang = false;
            this.fashe2 = true;
            if (this.upgradeNumber2 == 100) {
                this.removeChild(this.bj);
                this.upgradeNumber4 = 0;
                this.upgradeNumber3 = 0;
                tanChuang = 0;
                this.upgradeNumber2 = 0;
            }
        }
        else {
            if (tishi < 8) {
                /**新手指导 */
                this.Newarrow.visible = false;
                this.Newarrow1.visible = false;
                if (this.upgradeNumber4 == 1) {
                    // if(this.upgradeNumber2 !=100){
                    // this.fenxiang = false;
                    // this.fashe2 = true;
                    this.removeChild(this.bj);
                    this.upgradeNumber4 = 0;
                    this.upgradeNumber3 = 0;
                    tanChuang = 0;
                    this.upgradeNumber2 = 0;
                    // }else{
                    //      this.removeChild(this.bj);
                    //     this.upgradeNumber4 = 0;
                    //     this.upgradeNumber3 = 0;
                    //     this.upgradeNumber2 = 0;
                    // }
                }
                //          if (this.upgradeNumber4 == 6) {//新手引导
                //             this.removeChild(this.bj);
                //             this.removeChild(this.btn);
                // this.upgradeNumber4 =0;
                //             this.upgradeNumber3 = 0;
                //             this.upgradeNumber2 = 0;
                //         }
                /**新手指导箭头指示 */
                if (tishi == 3) {
                    this.addChild(this.Newjiantou);
                    this.Newjiantou.x = 360;
                    this.Newjiantou.y = 560;
                    this.Newjiantou.rotation = -30;
                    egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                }
                if (tishi == 4) {
                    this.Newjiantou.visible = true;
                    this.Newjiantou.x = 60;
                    this.Newjiantou.y = 210;
                    egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                }
                if (tishi == 5 || tishi == 8) {
                    this.Newjiantou.visible = true;
                    this.Newjiantou.x = 360;
                    this.Newjiantou.y = 560;
                    egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                }
                // console.log("weqwddbwerwrw提示" + tishi);
                if (tishi == 6) {
                    this.Newjiantou.visible = true;
                    this.Newjiantou.x = 90;
                    this.Newjiantou.y = 460;
                    egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                }
                if (tishi == 7) {
                    this.Newjiantou.visible = true;
                    this.Newjiantou.x = 360;
                    this.Newjiantou.y = 260;
                    egret.Tween.get(this.Newjiantou, { loop: true }).to({ alpha: 1 }, 300).to({ alpha: 0 }, 300);
                }
                if (this.upgradeNumber4 == 2) {
                    this.upgradeNumber2 = 0;
                    this.removeChild(this.bj);
                    var timer2 = new egret.Timer(500, 1);
                    //注册事件侦听器
                    timer2.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerComFunc22, this);
                    //开始计时
                    timer2.start();
                    this.upgradeNumber3 = 0;
                    tanChuang = 0;
                    this.upgradeNumber4 = 3;
                }
            }
            console.log("-----------------------------------------------------------");
            // var shanfa = new MImage("小轮_png");
            // this.addChild(shanfa);
            // shanfa.x = 497;
            // shanfa.y = 977;
            // shanfa.scaleX = 0.5;
            // shanfa.scaleY = 0.5;
            // egret.Tween.get(shanfa).to({ scaleX: 0.7, scaleY: 0.7 }, 500).call(() => { this.removeChild(shanfa) })
            // egret.Tween.get(shanfa).to({ alpha: 0 }, 500)
        }
    };
    GameControl.prototype.timerComFunc22 = function () {
        this.upgradeNumber2 = 4;
        this.UpgradeTishi();
    };
    GameControl.prototype.endBackFun = function (posEnd) {
        var g_un;
        if (this.istop) {
            g_un = this.guntop;
        }
        if (!this.istop) {
            g_un = this.gun;
        }
        this.fenxiang = true;
        if (this.fashezhuo != null) {
            posEnd = this.fashezhuo;
        }
        var pos = new egret.Point(posEnd.x - g_un.x, posEnd.y - g_un.y);
        var angle = Math.atan2(pos.x, pos.y);
        var dis = 10000;
        var x = Math.ceil(Math.sin(angle) * dis);
        var y = Math.ceil(Math.cos(angle) * dis);
        this.vec = new egret.Point(x, y);
        // ball.velocity=[x,y]
        this.ballNum = g_un.bullet;
        // this.ballNum = 50;
        this.shape.visible = true; //与球碰撞反射线显示
        this.shape1.visible = false;
        g_un.fire();
    };
    /**开火 */
    GameControl.prototype.onFire = function (e) {
        this.overValue = 0;
        this.isChanger = 0;
        this.isStrike = 0;
        this.bianliang = 0;
        this.Collidetime.shuzi = 0;
        this.Collidetime.updateNum(this.Collidetime.shuzi); //开枪前将碰撞数改为0
        console.log("this.bullet333333333333333333子弹的剩余数量" + this.my_chuchun.length);
        if (this.qiehuan) {
            this.NowBullet.isRun = false;
        }
        if (this.NowBullet.isRun) {
            this.fashe2 = false;
            if (this.NowBullet.objkind == 301) {
                this.adjustment.visible = true;
                var b = this.NowBullet.runEnd();
                this.Collidetime.shuzi = 0;
                //  this.getPoint(b);
                this.my_ball.push(b);
                if (this.huiheNum >= 2) {
                    this.istop = !this.istop;
                    this.qiehuan = false;
                    this.huiheNum = 0;
                }
                // if (this.boomNum >= 4) {//二次点击时判断第五次出来炸弹
                //     this.NowBullet = this.boomBullet;
                //     this.NowBullet1 = this.boomBullet;
                //    this.boomNum = 0;
                //     this.restrictNumber = 1;//限制四次后直接进入runend方法
                // }
                // this.changeColor();
            }
            if (this.NowBullet.objkind == 102 && this.restrictNumber != 1) {
                this.NowBullet.runEnd();
                // if (this.boomNum == 5 && this.NowBullet.isRun == false) {
                //     this.NowBullet = this.boomBullet;
                //  this.boomNum = 0;
                //     // this.changeBullet();
                //     this.changeColor();
                // }
            }
            if (this.NowBullet.objkind == 103) {
                var b = this.NowBullet.runEnd();
                //  this.getPoint(b);
                this.my_ball.push(b);
                this.changeBullet();
                this.changeColor();
            }
            if (this.NowBullet.objkind == 104) {
                this.NowBullet.m_body.type = 1;
                this.bianliang = 1;
                this.NowBullet.m_body.damping = 1; //阻力变1
                this.gravityTime = new egret.Timer(100, 1);
                this.gravityTime.start(); //开始计时
                this.gravityTime.addEventListener(egret.TimerEvent.TIMER, this.jishi, this); //计时中事件
                if (this.NowBullet1 == null) {
                    this.changeBullet();
                    this.changeColor();
                }
            }
            if (this.NowBullet.objkind == 105) {
                var b = this.NowBullet.runEnd1();
                //  this.getPoint(b);
                //    this.my_ball.push(b);
                this.my_strikeBall.push(b);
                this.Striketime.chufashuzi = 3;
                if (this.propCount == 0) {
                    this.changeBullet();
                }
                this.changeColor();
            }
            this.restrictNumber = 0;
            if (this.gun.bullet <= 0 && this.NowBullet.isRun == false) {
                this.over();
            }
            // if (this.boomNum != 0) {
            //     this.NowBullet = this.fakeBullet;
            // }
            if (this.NowBullet1 != null) {
                this.changeColor1();
            }
        }
        else if (this.NowBullet.isRun == false && !this.sffaqiu && this.my_chuchun.length != 0 && this.fashe2) {
            this.adjustment.visible = false;
            this.huiheNum++;
            var g_un;
            if (this.istop) {
                g_un = this.guntop;
            }
            if (!this.istop) {
                g_un = this.gun;
            }
            console.log("this.bullet子弹的剩余数量" + this.my_chuchun.length);
            SoundControl.getIns().play(MUSIC_FIRE);
            this.shape.graphics.clear(); //开火按下清除反射线
            this.fashe2 = false;
            this.jiaQiuCount = 0; //加子弹数每轮清空
            if (this.propCount > 0) {
                --this.propCount;
            }
            g_un.hideLine();
            this.shu11 = 0;
            if (g_un.bullet > 0) {
                // if (this.NowBullet1 != null) {
                //     this.NowBullet = this.NowBullet1;
                //     // this.NowBullet1 = null;
                // }
                if (this.my_chuchun[0].objkind == 2) {
                    this.NowBullet = this.strikeBullet;
                }
                else if (this.my_chuchun[0].objkind == 3) {
                    this.NowBullet = this.MagnifyBullet;
                }
                else if (this.my_chuchun[0].objkind == 4) {
                    this.NowBullet = this.gravityBullet;
                    ;
                }
                else if (this.my_chuchun[0].objkind == 5) {
                    this.NowBullet = this.boomBullet;
                }
                else {
                    if (this.qiehuan) {
                        this.NowBullet = this.Bulebullet;
                    }
                    else {
                        this.NowBullet = this.fakeBullet;
                    }
                }
                this.boomNum += 1;
                if (this.my_chuchun[0].objkind != 1) {
                    this.boomNum = 0;
                }
                this.removeChild(this.my_chuchun[0].tu);
                this.my_chuchun.splice(0, 1);
                this.NowBullet.send(g_un.x, g_un.y, this.vec.x, this.vec.y);
                g_un.updateNum(--(g_un.bullet)); //减子弹数量              
                // if (this.gun.bullet <= 0) {
                //     var timer: egret.Timer = new egret.Timer(1200, 1);
                //     timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.destoryjinbi, this);
                //     timer.start();
                // }
                // if(this.tishi2==0){
                //     this.tishi2=1;
                //     this.upgradeNumber2=2;//新手引导
                //  	this.UpgradeTishi();//新手引导
                // }
                if (this.daojutishi == 1) {
                    this.daojutishi = 2;
                    this.upgradeNumber2 = 6;
                    this.UpgradeTishi();
                }
                var q = 1;
                // console.log("子弹里的数量***********"+this.gun.bullet);
                //  console.log("弹夹里的数量"+this.my_chuchun.length);
                //  console.log("执行加子弹");3333333
                if (g_un.bullet >= this.my_chuchun.length) {
                    //console.log("执行加子弹");
                    this.jiandan();
                }
                // if (this.gun.bullet == this.my_chuchun.length) {
                //     this.shangdan();
                // }
                g_un.ball.visible = false;
                g_un.redball.visible = false;
                g_un.magnify.visible = false;
                g_un.gravity.visible = false;
                g_un.strike.visible = false;
            }
            if (this.qiehuan) {
                this.NowBullet.isRun = false;
                this.fashe.visible = false;
            }
        }
    };
    // public destoryjinbi()//新手引导
    // {
    //     GameControl.GameControlSole.empty1();//清空场景里存在的金币
    // }
    /**加子弹 */
    GameControl.prototype.jiandan = function () {
        //     if (this.my_chuchun2.length > 0) {
        //         var a = new chun;
        //         a.tu = new MImage(lizitexiao[this.my_chuchun2[0]])
        //         a.objkind = this.my_chuchun2[0];
        //         a.tu.anchorOffsetX = a.tu.width / 2;
        //         a.tu.anchorOffsetY = a.tu.height / 2;
        //         a.tu.x = 400;//264
        //         a.tu.y = 1000;//922
        //         this.addChild(a.tu);
        //         this.my_chuchun.push(a);
        //         this.my_chuchun2.splice(0, 1);
        //     } else {
        var a1 = new chun;
        a1.tu = new MImage("ball_png");
        a1.objkind = 1;
        a1.tu.anchorOffsetX = a1.tu.width / 2;
        a1.tu.anchorOffsetY = a1.tu.height / 2;
        a1.tu.x = 319; //264
        a1.tu.y = 950; //922
        this.addChild(a1.tu);
        this.my_chuchun.push(a1);
        // }
        // this.shangdan();
    };
    // /**传最新位置 */
    // public position() {
    //     this.gravityResult(this.NowBullet.m_body.position[0], this.NowBullet.m_body.position[1]);
    // }
    GameControl.prototype.jishi = function () {
        this.NowBullet.runEnd(16, 9999);
        this.Collidetime.x = -55;
        this.Collidetime.y = -55;
    };
    /** 距离右边的距离*/
    GameControl.prototype.getRight = function (distance) {
        return GameData.stageWidth - distance;
    };
    /** 距离右边的距离*/
    GameControl.prototype.getBottom = function (distance) {
        return GameData.stageHeight - distance;
    };
    /** 传入宽后居中距离*/
    GameControl.prototype.getCenterX = function (skinWidth) {
        return (GameData.stageWidth - skinWidth) >> 1;
    };
    /**设置与球的碰撞弹性 */
    GameControl.prototype.doMaterial = function (ball) {
        var world = this.world;
        var bodys = world.p2World.bodies;
        var l = bodys.length;
        for (var i = 0; i < l; i++) {
            var body = bodys[i];
            if (body.userData["hit"]) {
                this.setMaterial(ball, body);
            }
        }
    };
    /** 设置刚体碰撞的弹性*/
    GameControl.prototype.setMaterial = function (body1, body2) {
        var material = this.material;
        body1.shapes[0].material = material;
        body2.shapes[0].material = material;
        var roleAndStoneMaterial = new p2.ContactMaterial(material, material, { restitution: 0.7, friction: 0 }); //弹性，摩擦力
        this.world.p2World.addContactMaterial(roleAndStoneMaterial);
    };
    /**设置属性后就可以与球碰撞 */
    GameControl.prototype.setAndBallHit = function (body) {
        var shape = body.shapes[0];
        shape.collisionMask = 6; //010与001为0，010与110为1
    };
    /** 创建球刚体*/
    GameControl.prototype.createBall = function () {
        var world = this.world;
        var skin = this.createSkin("ball_png");
        var body = world.createCircleBodyShape(skin.width >> 1);
        body.userData.skin = skin;
        body.userData["ball"] = true;
        body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
        //body.gravityScale=0;
        var shape = body.shapes[0];
        shape.collisionGroup = 2; //010与001为0，010与110为1
        // shape.collisionMask=2;
        //trace(shape.collisionGroup,shape.collisionMask)
        return body;
    };
    /** 创建皮肤*/
    GameControl.prototype.createSkin = function (name) {
        var skin = new NumImage(name);
        skin.x = -500; //避免在一出现的时候会在左上角闪现
        skin.setAnchorCenter();
        this.addChild(skin);
        return skin;
    };
    GameControl.prototype.loopP2World = function () {
        // var bodys = this.world.p2World.bodies;
        // //traceSimple("bodys",bodys.length);
        // var l: number = bodys.length;
        // for (var i: number = 0; i < l; i++) {
        //     var body: p2.Body = bodys[i];
        //     if (body.userData && body.userData.skin) {
        //         if (body.userData["ball"]) {
        //             var vec = new Point(body.velocity[0], body.velocity[1]);
        //             var vecnum: number = Math.sqrt(vec.x * vec.x + vec.y * vec.y);
        //             if (vecnum < 1) {
        //                 console.log(vecnum);
        //                 this.setBallImpulse(body);
        //             }
        //         }
        //     }
        // }
    };
    GameControl.prototype.loop = function (n) {
        var skins = this.removeSkins;
        // traceSimple(skins.length)
        for (var i = 0; i < skins.length; i++) {
            var skin = skins[i];
            skin.removeFromParent(true);
        }
        if (this.ballNum == 0) {
            this.nextLevel();
        }
        return true;
    };
    GameControl.prototype.nextLevel = function () {
        this.ballNum = this.gun.bulletMax;
        this.removeSkins.length = 0;
        this.updateNumBody();
        this.gun.initNum();
    };
    GameControl.prototype.setGameHandle = function (game) {
        this.gameHandle = game;
    };
    /**2 排行榜按钮绑定事件*/
    GameControl.prototype.paihangBtnClick = function () {
        var _this = this;
        var openDataContext = wx.getOpenDataContext();
        if (this.isdisplay) {
            console.log("点击后：" + this.isdisplay);
            this.bitmap.parent && this.bitmap.parent.removeChild(this.bitmap);
            this.rankingListMask.parent && this.rankingListMask.parent.removeChild(this.rankingListMask);
            this.closeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.paihangBtnClick, this);
            this.closeBtn.parent.removeChild(this.closeBtn);
            this.isdisplay = false;
        }
        else {
            //处理遮罩，避免开放数据域事件影响主域。
            this.rankingListMask = new egret.Shape();
            this.rankingListMask.graphics.beginFill(0x000000, 1);
            this.rankingListMask.graphics.drawRect(0, 0, this.gameHandle.stage.width, this.gameHandle.stage.height);
            this.rankingListMask.graphics.endFill();
            this.rankingListMask.alpha = 0.5;
            this.rankingListMask.touchEnabled = true;
            this.gameHandle.addChild(this.rankingListMask);
            console.log("调取开放域");
            //简单实现，打开这关闭使用一个按钮。
            //this.gameHandle.addChild(this.gameHandle.paihang);
            //主要示例代码开始
            var bitmapdata_1 = new egret.BitmapData(window["sharedCanvas"]);
            bitmapdata_1.$deleteSource = false;
            var texture = new egret.Texture();
            texture._setBitmapData(bitmapdata_1);
            this.bitmap = new egret.Bitmap(texture);
            this.bitmap.width = this.gameHandle.stage.stageWidth;
            this.bitmap.height = this.gameHandle.stage.stageHeight;
            this.gameHandle.addChild(this.bitmap);
            this.closeBtn = new MImage("addIcon_png");
            this.closeBtn.touchEnabled = true;
            egret.setTimeout(function (e) {
                _this.gameHandle.addChild(_this.closeBtn);
            }, this, 30);
            this.closeBtn.x = 550;
            this.closeBtn.y = 200;
            console.log("点击前：" + this.isdisplay);
            this.isdisplay = true;
            this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.paihangBtnClick, this);
            egret.startTick(function (timeStarmp) {
                egret.WebGLUtils.deleteWebGLTexture(bitmapdata_1.webGLTexture);
                bitmapdata_1.webGLTexture = null;
                return false;
            }, this);
            //主要示例代码结束    
            this.isdisplay = true;
        }
        //发送消息
        openDataContext.postMessage({
            isDisplay: this.isdisplay,
            text: 'hello',
            year: (new Date()).getFullYear()
        });
    };
    return GameControl;
}(moon.BasicGamePanel));
__reflect(GameControl.prototype, "GameControl");
/**分数图标*/
var NumImage = (function (_super) {
    __extends(NumImage, _super);
    function NumImage(skinName) {
        if (skinName === void 0) { skinName = ""; }
        var _this = _super.call(this, skinName) || this;
        _this._value = -1;
        return _this;
    }
    NumImage.prototype.initNum = function (v) {
        this.txt = this.createText(0, 0);
        if (this.skinName == ICON_ADD) {
            this._value = 1;
        }
        else {
            this.value = v;
        }
    };
    NumImage.prototype.createText = function (x, y, s) {
        if (x === void 0) { x = 0; }
        if (y === void 0) { y = 0; }
        if (s === void 0) { s = ""; }
        var text = (new moon.Label).textField;
        text.x = x;
        text.y = y;
        text.text = s;
        this.addChild(text);
        return text;
    };
    Object.defineProperty(NumImage.prototype, "value", {
        get: function () {
            return this._value;
        },
        set: function (v) {
            this._value = v;
            this.txt.text = String(v);
            this.txt.textColor = 0;
            if (this.parent != null) {
                Layout.getIns().setCenterXByPanent(this.txt);
                Layout.getIns().setCenterYByPanent(this.txt);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NumImage.prototype, "imageName", {
        get: function () {
            return this.skinName;
        },
        enumerable: true,
        configurable: true
    });
    NumImage.prototype.update = function () {
        this._value--;
        this.value = this._value;
        if (this.imageName == ICON_ADD) {
            SoundControl.getIns().play(MUSIC_ADDNUM);
        }
        else {
            SoundControl.getIns().play(MUSIC_HIT);
        }
    };
    return NumImage;
}(MImage));
__reflect(NumImage.prototype, "NumImage");
/**普通球碰撞次数显示 */
var collideTime = (function (_super) {
    __extends(collideTime, _super);
    function collideTime() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.shuzi = 0;
        return _this;
    }
    collideTime.prototype.render = function () {
        this.txtNum1 = this.createText(0, 0, "0");
        this.txtNum1.textColor = 0x000000;
        this.txtNum1.size = 30;
    };
    collideTime.prototype.updateNum = function (value) {
        this.txtNum1.text = String(value);
        this.txtNum1.anchorOffsetX = this.txtNum1.width - 10 >> 1;
        this.txtNum1.anchorOffsetY = this.txtNum1.height - 5 >> 1;
    };
    return collideTime;
}(moon.BasicView));
__reflect(collideTime.prototype, "collideTime");
/**触发球碰撞次数显示 */
var strikeTime = (function (_super) {
    __extends(strikeTime, _super);
    function strikeTime() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.chufashuzi = 3;
        return _this;
    }
    strikeTime.prototype.render = function () {
        this.txtNum2 = this.createText(0, 0, "0");
        this.txtNum2.textColor = 0x000080;
        this.txtNum2.size = 30;
    };
    strikeTime.prototype.updateNum = function (value) {
        this.txtNum2.text = String(value);
        this.txtNum2.anchorOffsetX = this.txtNum2.width - 10 >> 1;
        this.txtNum2.anchorOffsetY = this.txtNum2.height - 5 >> 1;
    };
    return strikeTime;
}(moon.BasicView));
__reflect(strikeTime.prototype, "strikeTime");
/**分享按钮 */
var shareButton = (function (_super) {
    __extends(shareButton, _super);
    function shareButton() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    shareButton.prototype.initView = function () {
        var share = new MButton(new MImage("circle3_png"), new MImage("circle3_png"));
        share.anchorOffsetX = share.width >> 1;
        share.x = 15;
        share.y = -80;
        this.addChild(share);
        this.share = share;
    };
    return shareButton;
}(moon.BasicGameStart));
__reflect(shareButton.prototype, "shareButton");
/**储存子弹 */
var chun = (function (_super) {
    __extends(chun, _super);
    function chun() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return chun;
}(moon.BasicView));
__reflect(chun.prototype, "chun");
/**枪*/
var Gun = (function (_super) {
    __extends(Gun, _super);
    function Gun() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.restcishu = 0; //新手引导
        return _this;
    }
    Gun.prototype.render = function () {
        var gun = new MImage("gun_png");
        gun.anchorOffsetX = gun.width / 2;
        gun.anchorOffsetY = gun.height / 2;
        // this.addChild(gun);
        this.gun = gun;
        var numBg = new MImage("purpleBall_png");
        numBg.setAnchorCenter();
        //  this.addChild(numBg);
        var line = new MImage("line23_png");
        line.anchorOffsetX = line.width + 8.4 >> 1;
        this.line = line;
        this.txtNum = this.createText(20, 140, "");
        this.txtNum.textColor = 0x00c4a851;
        this.bullet = this.bulletMax;
        this.updateNum(this.bullet);
        var Ball = new MImage("ball_png");
        Ball.anchorOffsetX = Ball.width / 2;
        Ball.anchorOffsetY = Ball.height / 2;
        this.addChild(Ball);
        this.ball = Ball;
        var Ball2 = new MImage("redball2_png");
        Ball2.anchorOffsetX = Ball2.width / 2;
        Ball2.anchorOffsetY = Ball2.height / 2;
        this.addChild(Ball2);
        this.redball = Ball2;
        this.redball.visible = false;
        var Ball3 = new MImage("purpleBall_png");
        Ball3.anchorOffsetX = Ball3.width / 2;
        Ball3.anchorOffsetY = Ball3.height / 2;
        this.addChild(Ball3);
        this.magnify = Ball3;
        this.magnify.visible = false;
        var Ball4 = new MImage("zhongli_png");
        Ball4.anchorOffsetX = Ball4.width / 2;
        Ball4.anchorOffsetY = Ball4.height / 2;
        this.addChild(Ball4);
        this.gravity = Ball4;
        this.gravity.visible = false;
        var Ball5 = new MImage("chu_png");
        Ball5.anchorOffsetX = Ball5.width / 2;
        Ball5.anchorOffsetY = Ball5.height / 2;
        this.addChild(Ball5);
        this.strike = Ball5;
        this.strike.visible = false;
    };
    Gun.prototype.restart = function () {
        // if (this.restcishu == 0) {//&&egret.localStorage.getItem("xinshouyindao") == "false") {//新手引导
        //     this.bulletMax = 100;//初始子弹数量
        //     this.restcishu = 1;
        // }
        // else {
        //     // GameControl.GameControlSole.empty1();//清空所有刚体
        //     this.bulletMax = 10;//初始子弹数量
        // }//新手引导
        //  if (egret.localStorage.getItem("xinshouyindao") == "false") {
        if (tishi < 9) {
            // if (this.restcishu == 0) {//&&egret.localStorage.getItem("xinshouyindao") == "false") {//新手引导
            this.bulletMax = 100; //初始子弹数量
            console.log("初始子弹数量111111111111" + this.bulletMax);
            this.restcishu = 1;
            //  }
            // this.bulletMax = 10;
        }
        else {
            this.bulletMax = 100;
            console.log("初始子弹数量22222222222222" + this.bulletMax);
        }
        this.initNum();
    };
    Gun.prototype.updatePos = function (pos) {
        var r = -Math.atan2(pos.x, pos.y) * 180 / Math.PI;
        this.gun.rotation = r;
        this.line.rotation = r;
        this.ball.rotation = r;
        this.redball.rotation = r;
        this.magnify.rotation = r;
        this.gravity.rotation = r;
        this.strike.rotation = r;
    };
    Gun.prototype.initNum = function () {
        this.bullet = this.bulletMax;
        this.updateNum(this.bullet);
    };
    Gun.prototype.showLine = function () {
        this.addChildAt(this.line, 0);
        this.lineBool = true;
        Tween.get(this.line).to({ alpha: 1 }, 200);
    };
    Gun.prototype.hideLine = function () {
        var _this = this;
        // this.line.removeFromParent();
        this.lineBool = false;
        Tween.get(this.line).to({ alpha: 0 }, 200).call(function () {
            _this.line.removeFromParent();
        });
    };
    Gun.prototype.updateNum = function (value) {
        console.log("炮弹数量：" + value);
        this.txtNum.text = String(value);
        this.txtNum.anchorOffsetX = this.txtNum.width >> 1;
        this.txtNum.anchorOffsetY = this.txtNum.height >> 1;
    };
    Gun.prototype.fire = function () {
        if (this.bullet >= 0) {
            // console.log("1111111111子弹剩余数量" + this.bullet);
            // this.updateNum(--this.bullet);
            Tween.get(this.gun).to({ scaleY: 0.6 }, 100).to({ scaleY: 1 }, 100);
            this.dispEvent(EVENT_FIRE);
            // setTimeout(this.fire.bind(this), 300);
            // this.ball.visible=false;
        }
    };
    return Gun;
}(moon.BasicView));
__reflect(Gun.prototype, "Gun");
var GunTop = (function (_super) {
    __extends(GunTop, _super);
    function GunTop() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.restcishu = 0; //新手引导
        return _this;
    }
    GunTop.prototype.render = function () {
        var gun = new MImage("gun_png");
        gun.anchorOffsetX = gun.width / 2;
        gun.anchorOffsetY = gun.height / 2;
        this.addChild(gun);
        this.gun = gun;
        var numBg = new MImage("purpleBall_png");
        numBg.setAnchorCenter();
        this.addChild(numBg);
        var line = new MImage("line23_png");
        line.anchorOffsetX = line.width + 8.4 >> 1;
        this.line = line;
        this.txtNum = this.createText(0, -100, "");
        this.txtNum.textColor = 0x00c4a851;
        this.bullet = this.bulletMax;
        this.updateNum(this.bullet);
        var Ball = new MImage("ball_png");
        Ball.anchorOffsetX = Ball.width / 2;
        Ball.anchorOffsetY = Ball.height / 2;
        this.addChild(Ball);
        this.ball = Ball;
        var Ball2 = new MImage("redball2_png");
        Ball2.anchorOffsetX = Ball2.width / 2;
        Ball2.anchorOffsetY = Ball2.height / 2;
        this.addChild(Ball2);
        this.redball = Ball2;
        this.redball.visible = false;
        var Ball3 = new MImage("purpleBall_png");
        Ball3.anchorOffsetX = Ball3.width / 2;
        Ball3.anchorOffsetY = Ball3.height / 2;
        this.addChild(Ball3);
        this.magnify = Ball3;
        this.magnify.visible = false;
        var Ball4 = new MImage("zhongli_png");
        Ball4.anchorOffsetX = Ball4.width / 2;
        Ball4.anchorOffsetY = Ball4.height / 2;
        this.addChild(Ball4);
        this.gravity = Ball4;
        this.gravity.visible = false;
        var Ball5 = new MImage("chu_png");
        Ball5.anchorOffsetX = Ball5.width / 2;
        Ball5.anchorOffsetY = Ball5.height / 2;
        this.addChild(Ball5);
        this.strike = Ball5;
        this.strike.visible = false;
    };
    GunTop.prototype.restart = function () {
        // if (this.restcishu == 0) {//&&egret.localStorage.getItem("xinshouyindao") == "false") {//新手引导
        //     this.bulletMax = 100;//初始子弹数量
        //     this.restcishu = 1;
        // }
        // else {
        //     // GameControl.GameControlSole.empty1();//清空所有刚体
        //     this.bulletMax = 10;//初始子弹数量
        // }//新手引导
        //  if (egret.localStorage.getItem("xinshouyindao") == "false") {
        if (tishi < 9) {
            // if (this.restcishu == 0) {//&&egret.localStorage.getItem("xinshouyindao") == "false") {//新手引导
            this.bulletMax = 100; //初始子弹数量
            console.log("初始子弹数量111111111111" + this.bulletMax);
            this.restcishu = 1;
            //  }
            // this.bulletMax = 10;
        }
        else {
            this.bulletMax = 100;
            console.log("初始子弹数量22222222222222" + this.bulletMax);
        }
        this.initNum();
    };
    GunTop.prototype.updatePos = function (pos) {
        var r = -Math.atan2(pos.x, pos.y) * 180 / Math.PI;
        this.gun.rotation = r;
        this.line.rotation = r;
        this.ball.rotation = r;
        this.redball.rotation = r;
        this.magnify.rotation = r;
        this.gravity.rotation = r;
        this.strike.rotation = r;
    };
    GunTop.prototype.initNum = function () {
        this.bullet = this.bulletMax;
        this.updateNum(this.bullet);
    };
    GunTop.prototype.showLine = function () {
        this.addChildAt(this.line, 0);
        this.lineBool = true;
        Tween.get(this.line).to({ alpha: 1 }, 200);
    };
    GunTop.prototype.hideLine = function () {
        var _this = this;
        // this.line.removeFromParent();
        this.lineBool = false;
        Tween.get(this.line).to({ alpha: 0 }, 200).call(function () {
            _this.line.removeFromParent();
        });
    };
    GunTop.prototype.updateNum = function (value) {
        console.log("炮弹数量：" + value);
        this.txtNum.text = String(value);
        this.txtNum.anchorOffsetX = this.txtNum.width >> 1;
        this.txtNum.anchorOffsetY = this.txtNum.height >> 1;
    };
    GunTop.prototype.fire = function () {
        if (this.bullet >= 0) {
            // console.log("1111111111子弹剩余数量" + this.bullet);
            // this.updateNum(--this.bullet);
            Tween.get(this.gun).to({ scaleY: 0.6 }, 100).to({ scaleY: 1 }, 100);
            this.dispEvent(EVENT_FIRE);
            // setTimeout(this.fire.bind(this), 300);
            // this.ball.visible=false;
        }
    };
    return GunTop;
}(moon.BasicView));
__reflect(GunTop.prototype, "GunTop");
var FrameAnimation = (function (_super) {
    __extends(FrameAnimation, _super);
    function FrameAnimation() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FrameAnimation.prototype.playAnimation = function (point) {
        var texture2mc = RES.getRes("Boom_png");
        var data2mc = RES.getRes("Boom_json");
        var mcFactory = new egret.MovieClipDataFactory(data2mc, texture2mc);
        var mc = new egret.MovieClip(mcFactory.generateMovieClipData("Boom"));
        mc.gotoAndPlay("Boom", 1); //"A" : Boom -1 ： 循环播放				
        mc.x = point.x;
        mc.y = point.y;
        //护盾
        // this.addChild();
        return mc;
    };
    return FrameAnimation;
}(egret.DisplayObjectContainer));
__reflect(FrameAnimation.prototype, "FrameAnimation");
//增大球子弹
var py2Obj;
(function (py2Obj) {
    var magnifyBullet = (function (_super) {
        __extends(magnifyBullet, _super);
        function magnifyBullet(world, gamePanle, romveSkins) {
            var _this = _super.call(this, world, gamePanle, romveSkins) || this;
            _this.isRun = false;
            _this.pointList = [];
            _this.objkind = 103;
            return _this;
        }
        magnifyBullet.prototype.init = function () {
            _super.prototype.init.call(this);
        };
        magnifyBullet.prototype.send = function (x, y, forcex, forcey) {
            this.m_body.type = 1;
            this.isRun = true;
            this.m_body.velocity = [0, 0];
            this.m_body.damping = 0;
            this.setPostion(x, y);
            this.setForce(forcex, forcey);
        };
        magnifyBullet.prototype.createMyRigidbody = function () {
            var world = this.m_world;
            var skin = this.createSkin("circle4_png");
            var body = world.createCircleBodyShape(45);
            body.userData.skin = skin;
            body.userData.data = this;
            body.mass = 0; //质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
            //body.gravityScale=0;
            var shape = body.shapes[0];
            shape.collisionGroup = 2; //010与001为0，010与110为1
            // shape.collisionMask=2;
            // trace(shape.collisionGroup,shape.collisionMask)
            return body;
        };
        magnifyBullet.prototype.createFixedBullet = function () {
        };
        magnifyBullet.prototype.runEnd = function () {
            var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
            bullet.init();
            bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
            this.m_gamePanle.doMaterial(bullet.getBody());
            // bullet.setForce(this.vec.x, this.vec.y);
            // this.setChildIndex(this.gun, this.numChildren - 1);
            this.isRun = false;
            this.recyle1();
            return bullet;
        };
        magnifyBullet.prototype.runEnd1 = function () {
            this.m_body.type = 3;
            this.isRun = true;
        };
        magnifyBullet.prototype.recyle1 = function () {
            this.m_body.velocity = [0, 0];
            this.m_body.type = 2;
            this.setPostion(-100, -100);
            this.isRun = false;
        };
        magnifyBullet.prototype.recyle = function () {
            this.isRun = true;
            this.m_body.type = 2;
            this.time = new egret.Timer(50, 1);
            this.time.start(); //开始计时
            this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
        };
        magnifyBullet.prototype.jishi = function () {
            this.isRun = true;
            this.m_body.type = 1;
        };
        magnifyBullet.prototype.strikeRecyle = function () {
            this.m_body.type = 3;
        };
        /**
         * Body.KINEMATIC = 4;
         * Body.STATIC = 2;
         * Body.DYNAMIC = 1;
         */
        magnifyBullet.prototype.getCollision = function (otherBody) {
            if (otherBody.objkind == 100) {
                return;
            }
            if (otherBody.objkind == 108) {
                this.strikeRecyle();
                var bb = 1;
            }
            if (bb == null) {
                this.recyle();
            }
        };
        return magnifyBullet;
    }(py2Obj.basicObj));
    py2Obj.magnifyBullet = magnifyBullet;
    __reflect(magnifyBullet.prototype, "py2Obj.magnifyBullet");
})(py2Obj || (py2Obj = {}));
;window.Main = Main;